#20279 closed Bug (invalid)
generic relation — at Version 1
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.contenttypes | Version: | 1.4 |
Severity: | Normal | Keywords: | |
Cc: | Simon Charette | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
While I used field names item_type
, item_id
instead of content_type
, object_id
to reference an object. and while delete the object, it will raise exception.
For example:
class ObjectPermission(models.Model): # implement object/row based permission # it support permission for all, for table and for object # the item_type, item_id designed to accept 0, as a wildcard permission = models.ForeignKey(Permission) item_type = models.ForeignKey(ContentType, blank=True, default=0, null=True) item_id = models.PositiveIntegerField(blank=True, default=0) item_object = generic.GenericForeignKey('item_type', 'item_id') class Publisher(models.Model): name = models.CharField(max_length=255)
I create an relation between publisher and object permission.
while delete a publisher in django admin, it will raise fielderror,
at query.py line 1320 raise FieldError("Cannot resolve keyword object into field. " "Choices are: %s" % (name, ", ".join(names)))
and after I change the field name back to content_type, object_id,
the exception won't appear.
The django doc didn't mentioned this behavior
Change History (1)
comment:1 by , 12 years ago
Component: | Uncategorized → contrib.contenttypes |
---|---|
Description: | modified (diff) |
Resolution: | → needsinfo |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Please re-open with the full traceback and use WikiFormating when providing code samples.