#26502: Lookup of attribute 'id' on model inheritance models in InlineModelAdmin
fails
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
Braintelligence |
Type: | Status: new
Uncategorized |
Component: | Version: 1.8
contrib.admin | Keywords: id, model inheritance, inherited
Severity: Normal | model, inline
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
-------------------------+-------------------------------------------------
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?
--
Ticket URL: <https://code.djangoproject.com/ticket/26502>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/058.925bf88b4fd871534145a42f3c17c3e7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.