-
-
Notifications
You must be signed in to change notification settings - Fork 302
Closed
Description
In a scenario where your base PolymorphicModel is abstract (for example, when you don't need a "simple" Project, a ForeignKey on it will cause field name clashes:
class BaseProject(PolymorphicModel):
owner = models.ForeignKey(User, related_name='projects')
class Meta:
abstract = True
class ArtProject(BaseProject):
# add some fields
pass
class ResearchProject(BaseProject):
# add some fields
passThis will cause the following errors (when running ./manage.py validate):
app.artproject: Accessor for field 'owner' clashes with related field 'User.projects'. Add a related_name argument to the definition for 'owner'.
app.artproject: Reverse query name for field 'owner' clashes with related field 'User.projects'. Add a related_name argument to the definition for 'owner'.
app.artproject: Accessor for field 'owner' clashes with related field 'User.projects'. Add a related_name argument to the definition for 'owner'.
app.artproject: Reverse query name for field 'owner' clashes with related field 'User.projects'. Add a related_name argument to the definition for 'owner'.
Same output for ResearchProject, the error gets printed twice for every model.
Is this by design or is a fix possible?
Some kind of workaround at the moment is defining the base model as not abstract, obviously at the cost of SQL overhead/performance.
Metadata
Metadata
Assignees
Labels
No labels