I dam trying to do this: http://docs.djangoproject.com/en/dev/topics/db/models/#be-careful-with-related-name
Using this style
This is saved as common/abstract.py
class OtherModel(models.Model):
something = Charfield(max_length=100)
class Meta:
abstract = True
class Base(models.Model):
fk_model = models.ForeignKey(OtherModel, related_name="%(app_label)s_%(class)s_related")
class Meta:
abstract = True
Then I import it into another file. Let's call this app/models.py
from common.abstract import Base
class ChildB(Base):
pass
I have installed 'app' but not the 'common'. It will import nicely without the FK or M2M relationship, but when I try to add it, I get this error:
/lib/python2.6/site-packages/django/db/models/fields/related.py", line 808, in init assert not to.meta.abstract, "%s cannot define a relation with abstract class %s" % (self.class._name__, to._meta.object_name) AssertionError: ForeignKey cannot define a relation with abstract class OtherModel
Please advise.... also let me know if you have any questions or don't understand something that I am explaining. The file that I working with is really complex, so I didn't want to post the whole thing since I knew that it is breaking on this one relationship.