#25354: Can't use related_query_name on an abstract base class
----------------------------------------------+--------------------
Reporter: jpulec | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
It currently isn't possible to set related_query_name on a field on an
abstract base class using the "%(class)s" or "%(app_label)s" string
formatting syntax that is allowed for the related_name parameter of field.
This is particularly problematic when trying to define an abstract base
class that uses a GenericRelation, since you can't specify a related_name,
but can specify a related_query_name.
For Example:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
class Child(models.Model):
object_id = PositiveIntegerField()
content_type = ForeignKey(ContentType)
content_object = GenericForeignKey()
class GenericMixin(models.Model):
relation = GenrericRelation(Child, related_query_name='%(class)s')
class Meta:
abstract = True
class Parent(GenericMixin):
name = CharField()
instance = Child.objects.filter(parents__name) # This query will not
work, as 'parents' is not set as the related_query_name for the Parent
Model
}}}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25354>
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/049.579e29dce79a46155720218a8bb5807b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.