#27460: GenericRelation doesn't work from AbstractClass to AbstractClass in
Django
1.10(.3)
-------------------------------------+-------------------------------------
Reporter: Wolfgang Grim | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 1.10
Severity: Normal | Resolution:
Keywords: GenericRelation, | Triage Stage:
Abstract, ContentFramework | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Alex Hill):
Hi Tim,
The message when you try to declare a normal relation to an abstract model
is this:
{{{
ag.DetailTest.something: (fields.E300) Field defines a relation with model
'AbstractSomething', which is either not installed, or is abstract.
}}}
I'll look at how we can catch the GenericRelation case in the same branch,
because that's much nicer.
Wolfgang: the trend in Django is to alert the user to problems earlier
rather than later, and I'm quite sure that's what's happening here. There
hasn't actually been any change in functionality since 1.9.
When you do `MasterTest.objects.filter(detail_Model__name="Test")`, Django
doesn't know which table to look for a matching "name" field in, because
the relation is generic and that information is stored in the database. It
would technically be possible to implement this, and return a
heterogeneous collection of objects that inherit from the abstract model,
but the code would be messy, it would be completely new ground for the
Django ORM, and for such a corner case I just don't think it would be
accepted.
There are third-party libraries that provide more polymorphism in Django,
and I'd recommend looking into those to see if they meet your needs. Here
are a couple:
https://django-polymorphic.readthedocs.io/en/stable/
https://django-model-
utils.readthedocs.io/en/latest/managers.html#inheritancemanager
--
Ticket URL: <https://code.djangoproject.com/ticket/27460#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.9d05be20232a4f1ca33e97565dea907b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.