98
If you have ForeignKey
relationships in an abstract base class every class inheriting from it will have this relationship. As a result of this you must not βhardcodeβ its related_name
, because all sub classes will try to create the same accessor on the realted class (TaskUser
in this case).
You should better do something like:
owner = models.ForeignKey(TaskUser, related_name="%(app_label)s_%(class)s_ownership")
See the django docs on this.
9
If you are using related_name in abstract base class you need to use a β%(app_label)sβ and β%(class)sβ in it.
Its mentioned in django doc
- [Django]-What is the path that Django uses for locating and loading templates?
- [Django]-Pass extra arguments to Serializer Class in Django Rest Framework
- [Django]-Django excluding specific instances from queryset without using field lookup
Source:stackexchange.com