[Answered ]-AttributeError: 'NoneType' object has no attribute 'attname'

1👍

I suspect the problem is due to the tenant_id model field you declared in your
ApplicationSetting model. Internally, the package you are using appears to use tenant_id as a reference to the field name of the tenant-related foreign key.

Since you declared tenant_id as a nullable field, the original tenant_id='organization_id' no longer exists. When you initialize your ApplicationSetting, the TenantManager looks for a field named None and tries to find it’s related name (via the attname property), hence the error.

To fix this, remove the tenant_id field.

After, you will probably get different exception, because your ApplicationSetting model doesn’t contain a field named organization. To fix this, you will need to rename your org field:

organization = models.ForeignKey(Organization,on_delete=models.CASCADE)'

Alternatively, you can change the tenant_id to org_id instead.

Disclaimer: I’m not at all familiar with the package you are using.

Leave a comment