I want to have an abstract Company
model in Django, and extend it depending on the type of the company involved:
class Company(models.Model):
name = models.CharField(max_length=100)
address = models.CharField(max_length=100)
class Meta:
abstract = True
class Buyer(Company):
# Buyer fields..
pass
class Seller(Company):
# Seller fields...
pass
Every user on the system is associated with a company, so I want to add the following to the User profile:
company = models.ForeignKey('Company')
But this gives the dreaded error:
main.Profile.company: (fields.E300) Field defines a relation with model 'Company', which is either not installed, or is abstract.
So I imagine what I'm trying to do cannot be done. I saw that the contenttypes framework could be used for this purpose, as answered in this question. My issue with that is that I don't want the company
field to point to any model, but just subclasses of the Company
model.
Is there anything else I can use for this purpose?