You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Django project with three separate apps, 'mainapp', 'app1', and 'app2'. The mainapp has a polymorphic model UniversalBaseSet, and app1 and app2 each have a model BaseSet which subclass from UniversalBaseSet.
Django gives me the following error:
app1.BaseSet.universalbaseset_ptr: (fields.E304) Reverse accessor for 'BaseSet.universalbaseset_ptr' clashes with reverse accessor for 'BaseSet.universalbaseset_ptr'.
HINT: Add or change a related_name argument to the definition for 'BaseSet.universalbaseset_ptr' or 'BaseSet.universalbaseset_ptr'.
app1.BaseSet.universalbaseset_ptr: (fields.E305) Reverse query name for 'BaseSet.universalbaseset_ptr' clashes with reverse query name for 'BaseSet.universalbaseset_ptr'.
HINT: Add or change a related_name argument to the definition for 'BaseSet.universalbaseset_ptr' or 'BaseSet.universalbaseset_ptr'.
app2.BaseSet.universalbaseset_ptr: (fields.E304) Reverse accessor for 'BaseSet.universalbaseset_ptr' clashes with reverse accessor for 'BaseSet.universalbaseset_ptr'.
HINT: Add or change a related_name argument to the definition for 'BaseSet.universalbaseset_ptr' or 'BaseSet.universalbaseset_ptr'.
app2.BaseSet.universalbaseset_ptr: (fields.E305) Reverse query name for 'BaseSet.universalbaseset_ptr' clashes with reverse query name for 'BaseSet.universalbaseset_ptr'.
HINT: Add or change a related_name argument to the definition for 'BaseSet.universalbaseset_ptr' or 'BaseSet.universalbaseset_ptr'.
Having worked with django-polymorphic before I know the _ptr is referring to the reference to the parent, but I don't know exactly what the issue is. Why does it look like each accessor or query name is clashing with itself?
Thanks for any help!
The text was updated successfully, but these errors were encountered:
I guess this is more of a Django thing than a django-polymorphic thing which makes sense given what django-polymorphic is doing (and not doing) under the hood.
It seems django is creating a OneToOneField in the background, so the solution is to create that field explicitly in the child models and set a related_name value to avoid the issue. https://stackoverflow.com/a/40344663/7144234
Hi,
I have a Django project with three separate apps, 'mainapp', 'app1', and 'app2'. The mainapp has a polymorphic model UniversalBaseSet, and app1 and app2 each have a model BaseSet which subclass from UniversalBaseSet.
Django gives me the following error:
Having worked with django-polymorphic before I know the _ptr is referring to the reference to the parent, but I don't know exactly what the issue is. Why does it look like each accessor or query name is clashing with itself?
Thanks for any help!
The text was updated successfully, but these errors were encountered: