Project

Profile

Help

Issue #4681

closed

Error caused by non-unique Master-Detail model names

Added by tustvold about 5 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
High
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
3. High
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 57
Quarter:

Description

When both pulp_deb and pulp_rpm are installed one gets the following error running django-admin makemigrations.

deb.Package.content_ptr: (fields.E304) Reverse accessor for 'Package.content_ptr' clashes with reverse accessor for 'Package.content_ptr'.
        HINT: Add or change a related_name argument to the definition for 'Package.content_ptr' or 'Package.content_ptr'.
deb.Package.content_ptr: (fields.E305) Reverse query name for 'Package.content_ptr' clashes with reverse query name for 'Package.content_ptr'.
        HINT: Add or change a related_name argument to the definition for 'Package.content_ptr' or 'Package.content_ptr'.
rpm.Package.content_ptr: (fields.E304) Reverse accessor for 'Package.content_ptr' clashes with reverse accessor for 'Package.content_ptr'.
        HINT: Add or change a related_name argument to the definition for 'Package.content_ptr' or 'Package.content_ptr'.
rpm.Package.content_ptr: (fields.E305) Reverse query name for 'Package.content_ptr' clashes with reverse query name for 'Package.content_ptr'.
        HINT: Add or change a related_name argument to the definition for 'Package.content_ptr' or 'Package.content_ptr'.
rpm.Package.release: (models.E006) The field 'release' clashes with the field 'release' from model 'core.content'.
rpm.UpdateRecord.release: (models.E006) The field 'release' clashes with the field 'release' from model 'core.content'.

My hypothesis, although I am new to django and so could be mistaken, is this is the result of pulpcore.app.models.Content, which is the base pulp_deb.app.models.Package and pulp_rpm.app.models.Package, not being abstract.

Django tries to create a reverse accessor on pulpcore.app.models.Content for each of the derived types but as they have the same name we get the above error.

One way of addressing this would be to make plugin authors either name their models more uniquely, or use parent_link and related_name to work around the issue. Alternatively one could make the Content model abstract, although I suspect there is some reason that it isn't. Either way this is probably a bug that should be fixed.


Related issues

Blocks Ansible Plugin - Task #4710: Rename AnsibleRole to just RoleCLOSED - CURRENTRELEASEbmbouter

Actions

Also available in: Atom PDF