#27460: GenericRelation doesn't work from AbstractClass to AbstractClass in
Django
1.10(.3)
-------------------------------------+-------------------------------------
Reporter: Wolfgang Grim | Owner: Alex Hill
Type: Bug | Status: assigned
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 Wolfgang Grim):
Hello! At least the following should work right?
{{{
from __future__ import unicode_literals
from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey,
GenericRelation
from django.contrib.contenttypes.models import ContentType
class AbstractDetail (models.Model):
class Meta: abstract=True
relatedTrackModel = GenericRelation("TrackDetail",
object_id_field='detailModel_id', content_type_field='detailModel_id',
related_query_name='%(app_label)s_%(class)s_detail_model')
class TrackDetail (models.Model):
detailModel_type = models.ForeignKey(ContentType, blank=True,
null=True)
detailModel_id = models.PositiveIntegerField(blank=True, null=True)
detail_Model = GenericForeignKey('detailModel_type', 'detailModel_id')
added = models.DateTimeField(null=True)
class DetailTest (AbstractDetail):
name = models.CharField(max_length=200, null=True)
pass
}}}
shell:
{{{
from testac.models import DetailTest, TrackDetail
from django.utils import timezone
dt = DetailTest.objects.create(name="name1")
track = TrackDetail.objects.create()
track.detail_Model=dt
track.added = timezone.now()
x =
TrackDetail.objects.filter(testac_detailtest_detail_model__name="name")
FieldError: Cannot resolve keyword 'testac_detailtest_detail_model' into
field. Choices are: %(app_label)s_%(class)s_detail_model, added,
detailModel_id, detailModel_type, detailModel_type_id, detail_Model, id
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27460#comment:7>
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.b8e3f26885f7ff6b7dbd3742329c70d9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.