Make HerokuConnect model my Django custom user model

5 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 Salesforce 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?
Reply all
Reply to author
Forward
0 new messages