Re: [Django] #35301: Overriding a @property of an abstract model with a GenericRelation causes a models.E025 error.

34 views
Skip to first unread message

Django

unread,
Mar 14, 2024, 7:23:04 AM3/14/24
to django-...@googlegroups.com
#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
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* cc: Adam Johnson (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted

Comment:

Thanks for the detailed report and early testing!
--
Ticket URL: <https://code.djangoproject.com/ticket/35301#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 14, 2024, 8:52:49 AM3/14/24
to django-...@googlegroups.com
#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 Adam Johnson):

Yeah thanks. I have an idea to fix this by keeping track of seen names
whilst iterating. Will give it a try tonight.
--
Ticket URL: <https://code.djangoproject.com/ticket/35301#comment:3>

Django

unread,
Mar 14, 2024, 10:01:27 AM3/14/24
to django-...@googlegroups.com
#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>

Django

unread,
Mar 16, 2024, 8:20:13 AM3/16/24
to django-...@googlegroups.com
#35301: Overriding a @property of an abstract model with a GenericRelation causes a
models.E025 error.
-------------------------------------+-------------------------------------
Reporter: Sage Abdullah | Owner: Adam
| Johnson
Type: Bug | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam Johnson):

* has_patch: 0 => 1
* owner: nobody => Adam Johnson
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35301#comment:5>

Django

unread,
Mar 17, 2024, 4:43:14 AM3/17/24
to django-...@googlegroups.com
#35301: Overriding a @property of an abstract model with a GenericRelation causes a
models.E025 error.
-------------------------------------+-------------------------------------
Reporter: Sage Abdullah | Owner: Adam
| Johnson
Type: Bug | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"7646b9023da7e1f6f3a871959db027b3ea36eebb" 7646b90]:
{{{#!CommitTicketReference repository=""
revision="7646b9023da7e1f6f3a871959db027b3ea36eebb"
Fixed #35301 -- Fixed Options._property_names for overriden properties.

Regression in faeb92ea13f0c1b2cc83f45b512f2c41cfb4f02d.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35301#comment:6>
Reply all
Reply to author
Forward
0 new messages