#28018 closed Bug (invalid)
OneToOneField not working with inlineadmin
Description (last modified by ) ¶
This class hierarchy doesn't work with inlineadmin:
class hierarchy:
models.py:
class d: pass class a: d = models.OneToOneField(d, on_delete=models.CASCADE, related_name="host") class b: pass
admin.py
class dInlineAdmin(admin.TabularInline): model = d @admin.register(b) class bSpecializedAdmin(admin.ModelAdmin): inlines = [ dInlineAdmin, ]
Error message:
<class 'x.admin.RequirementInlineAdmin'>: (admin.E202) 'x.Requirement' has no field named 'host'.
'host' is the related_name
Change History (4)
comment:2 by , 8 years ago
Component: | Uncategorized → contrib.admin |
---|---|
Type: | Uncategorized → Bug |
comment:3 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:4 by , 8 years ago
Description: | modified (diff) |
---|
Note:
See TracTickets
for help on using tickets.
I think, InlineModelAdmin works for models which have related objects. In your example,
model "b" is not related to model "d" and thus causing the exception. The following code will work