Opened 9 years ago
Last modified 9 years ago
#26502 closed Uncategorized
Lookup of attribute 'id' on model inheritance models in InlineModelAdmin fails — at Initial Version
Reported by: | Waldemar Hamm | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.8 |
Severity: | Normal | Keywords: | id, model inheritance, inherited model, inline |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Having two models, of which one inherits from another, for example:
class Person(models.Model): firstname = models.CharField(max_length=255, blank=True) lastname = models.CharField(max_length=255) class Author(Person): publisher = models.CharField(max_length=255)
I can't access the id field like so:
class AuthorInline(admin.StackedInline): model = Author fields = ['id', 'lastname', 'publisher'] class SomethingAdmin(admin.ModelAdmin): resource_class = Something inlines = [ AuthorInline ] list_display = ('somethinga', 'somethingb')
I get a KeyError and it says:
"Key 'id' not found in 'AuthorForm'"
Using Author._meta.get_all_field_names() the field id is definitely in the model, though. Removing 'id' from the fields list makes everything work.
Am I doing something wrong or is this a legit bug?
Note:
See TracTickets
for help on using tickets.