#11042 closed (fixed)
admin inlines of inherited models break on edit submit after changeset 10666
Reported by: | Jacob Smullyan | Owned by: | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
after r10666, an inline of an inherited model cannot be edited. The following traceback results upon submit:
Traceback: File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/contrib/admin/options.py" in wrapper 226. return self.admin_site.admin_view(view)(*args, **kwargs) File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/contrib/admin/sites.py" in inner 184. return view(request, *args, **kwargs) File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/db/transaction.py" in _commit_on_success 240. res = func(*args, **kw) File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/contrib/admin/options.py" in change_view 832. self.save_formset(request, form, formset, change=True) File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/contrib/admin/options.py" in save_formset 563. formset.save() File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/forms/models.py" in save 509. return self.save_existing_objects(commit) + self.save_new_objects(commit) File "/home/smulloni/.virtualenvs/jangle/lib/python2.5/site-packages/django/forms/models.py" in save_existing_objects 615. pk_value = form.fields[pk_name].clean(raw_pk_value).pk Exception Type: AttributeError at /admin/bobapp/bob/1/ Exception Value: 'NoneType' object has no attribute 'pk'
Reverse-merging r10666 makes the problem go away.
The trivial example code to reproduce the bug:
# models.py from django.db import models class Bob(models.Model): name=models.CharField(max_length=100) class Thing(models.Model): name=models.CharField(max_length=100) class FancyThing(Thing): is_fancy=models.BooleanField(default=True) bob=models.ForeignKey(Bob) #admin.py from django.contrib import admin from models import FancyThing, Bob class FancyThingInline(admin.StackedInline): model=FancyThing class BobAdmin(admin.ModelAdmin): inlines=[FancyThingInline] admin.site.register(Bob, BobAdmin)
Attachments (1)
Change History (7)
comment:1 by , 16 years ago
Owner: | changed from | to
---|
comment:2 by , 16 years ago
Component: | Uncategorized → django.contrib.admin |
---|---|
milestone: | → 1.1 |
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
Has patch: | set |
---|---|
Needs tests: | unset |
Owner: | removed |
This is really a bug introduced in [10666] that broke using subclassed models in admin inlines. #11042
The changeset introduced a function has_auto_field that checked for auto pk fields instead
of checking whether it has been automatically created.
I'm not so familiar with this area, can someone please review it?
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
verified that the bug is real