#31190 closed Bug (fixed)
prefetch_related() crashes for GenericForeignKey with custom related object ID.
Reported by: | Eugene Hatsko | Owned by: | Eugene Hatsko |
---|---|---|---|
Component: | contrib.contenttypes | Version: | 3.0 |
Severity: | Release blocker | Keywords: | GenericRelatedObjectManager |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On generic foreign key definition like:
obj = GenericForeignKey('object_content_type', 'object_id')
and
some_instances = GenericRelation('some_app.SomeModel', object_id_field='object_id', content_type_field='object_content_type')
On trying to get all some_instances, we get the next error:
AttributeError: 'SomeModel' object has no attribute 'content_type_id'
Attachments (1)
Change History (5)
comment:1 by , 5 years ago
Needs documentation: | set |
---|---|
Severity: | Normal → Release blocker |
Summary: | AttributeError: "GenericRelatedObjectManager" has hardcoded 'content_type_id' → AttributeError: "GenericRelatedObjectManager" has hardcoded 'content_type_id'. |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 5 years ago
Summary: | AttributeError: "GenericRelatedObjectManager" has hardcoded 'content_type_id'. → prefetch_related() crashes for GenericForeignKey with custom related object ID. |
---|
Note:
See TracTickets
for help on using tickets.
Thanks for this report.
Regression in dffa3e1992562ba60512d96d1eb5859ffff2ceb5.
Reproduced at e4bc4f26b27122f5887a5eea811ff985d9ab8b8d.