django-polymorphic icon indicating copy to clipboard operation
django-polymorphic copied to clipboard

Child can't Many To Many Parent

Open AstraLuma opened this issue 2 years ago • 2 comments

class Parent(PolymorphicModel):
    ...

class Child(Parent):
    spam = models.ManyToManyField(Parent)
$ ./manage.py makemigrations
SystemCheckError: System check identified some issues:

ERRORS:
myapp.Child.spam: (fields.E305) Reverse query name for 'myapp.Child.spam' clashes with reverse query name for 'myapp.Child.parent_ptr'.
	HINT: Add or change a related_name argument to the definition for 'myapp.Child.spam' or 'myapp.Child.parent_ptr'.

AstraLuma avatar Dec 20 '22 04:12 AstraLuma

I'm pretty sure this isn't an issue that's specific to django-polymorphic https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.ForeignKey.related_query_name

Does this fix your issue? Could this issue be closed?

AdamDonna avatar Nov 23 '23 10:11 AdamDonna

I honestly don't remember what I was trying to do at the time. Does this kind of self-reference work now?

AstraLuma avatar Nov 30 '23 04:11 AstraLuma