#35301: Overriding a @property of an abstract model with a GenericRelation causes a
models.E025 error.
-------------------------------------+-------------------------------------
Reporter: Sage Abdullah | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sage Abdullah):
Thanks both! Here's a much more minimal reproduction that still somewhat
makes sense.
{{{
from django.contrib.contenttypes.fields import GenericForeignKey,
GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.db import models
class Generic(models.Model):
content_type = models.ForeignKey(
ContentType,
related_name="+",
on_delete=models.CASCADE,
)
object_id = models.CharField(max_length=255)
content_object = GenericForeignKey()
class Abstract(models.Model):
@property
def generics(self):
return Generic.objects.filter(
content_type=ContentType.objects.get_for_model(self),
object_id=str(
self.pk),
)
class Meta:
abstract = True
class Concrete(Abstract):
generics = GenericRelation(Generic, related_query_name="concrete")
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/35301#comment:4>