Can't recover GenericForeignKey content type and object id field names
|Reported by:||kgoudeaux||Owned by:||nobody|
|Severity:||Keywords:||ContentType GenericForeignKey generic relations|
|Cc:||koen.biermans@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The GenericForeignKey class is perfect for recovering the object it references but leaves no way to recover itself and the field names it stores.
Its get function only returns the object it references or an error.
DoesNotExist when it isn't set on an instance.
AttributeError when accessed from the model class.
This one line patch and doc test changes the behavior of get to return the GenericForeignKey instance when accessed from the model class thereby allowing access to the content type and primary key field names.
Change History (6)
Changed 8 years ago by kgoudeaux <kgoudeaux@…>
comment:1 Changed 7 years ago by jacob
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Resolution set to wontfix
- Status changed from new to closed
comment:2 Changed 7 years ago by kgoudeaux@…
- Resolution wontfix deleted
- Status changed from closed to reopened
comment:4 Changed 7 years ago by jacob
- Triage Stage changed from Unreviewed to Design decision needed