django-heroku-connect icon indicating copy to clipboard operation
django-heroku-connect copied to clipboard

Make an HerokuConnect model the app's custom user model

Open Eliagandolfi opened this issue 4 years ago • 5 comments

I need to either extend/substitute my Django app's user model a HerokuConnect model Specifically, vendors registered in Salesforce should be able to login with their vendor_code__c as username

#models.py
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 (referred to this tutorial)

#models.py
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?

@codingjoe

Eliagandolfi avatar Jul 19 '19 08:07 Eliagandolfi