Make an Heroku connect model my app's custom user model

16 views
Skip to first unread message

Elia Gandolfi

unread,
Jul 17, 2019, 11:26:04 AM7/17/19
to Django users
# I want this Heroku-Connect model to be my app's custom user model.
# That means, vendors registered in my Salesforce database should be able to login with their vendor_code__c as username
class Vendor(hc_models.HerokuConnectModel):
sf_object_name = 'Vendor__c'

vendor_code = hc_models.ExternalID(sf_field_name='Vendor_Code__c', unique=True, upsert=False) # this should be the username
sf_id = hc_models.fields.ID(db_column='sfid', db_index=True, editable=False, max_length=18, sf_field_name='ID', unique=True, upsert=False)
name = hc_models.Text(sf_field_name='Name', max_length=80)
email = hc_models.Text(sf_field_name='Email__c', max_length=80)

# I've tried to replicate the vendor model with multi-table inheritance, found here
class vendoruser(Vendor):
hc_model = models.OneToOneField(Vendor, on_delete=models.CASCADE, to_field='vendor_code', parent_link=True, db_constraint=False)

# the idea is to extend the model from here. I do as in the example, but I get blocked right away with the following error

"""
salesforce.vendoruser: (heroku_connect.E006) salesforce.vendoruser.sf_object_name 'Vendor__c' clashes with another model.
HINT: Make sure your 'sf_object_name' is correct.
"""

# I've also tried to use hc_models.OneToOneField or hc_models.ForeignKey but it's not supported
# Any suggestion on how to work around this?

Yoo

unread,
Jul 17, 2019, 11:14:26 PM7/17/19
to Django users
Hi! I'm not fully acquainted with Heroku connect, but here's the pdf docs: https://buildmedia.readthedocs.org/media/pdf/django-heroku-connect/stable/django-heroku-connect.pdf on page 9 you can find:
heroku_connect.E006 The Salesforce object name must be unique since an object can only mapped to a PostgreSQL table once. 

Probably need to check the docs and see that two TABLES do NOT have the same name, according to the error. You might also want to check your other tables to make sure their attributes/columns are not the same. That's just theory, since I'm not too sure.
Reply all
Reply to author
Forward
0 new messages