Opened 12 years ago

Closed 12 years ago

#2484 closed defect (fixed)

[patch] num_in_admin=0 causes error on add via admin system

Reported by: jkocherhans Owned by: Adrian Holovaty
Component: contrib.admin Version: master
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Yes, I know setting num_in_admin to 0 is strange, I'm auto-generating the related objects in the save() method of the parent. The patch is pretty trivial.

With num_in_admin set to 0 on a related object, I get this error when trying to add via the admin interface:

Traceback (most recent call last):
File "/Users/jkocherhans/Projects/Django/trunk/django/core/handlers/" in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/jkocherhans/Projects/Django/trunk/django/contrib/admin/views/" in _checklogin
  55. return view_func(request, *args, **kwargs)
File "/Users/jkocherhans/Projects/Django/trunk/django/views/decorators/" in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File "/Users/jkocherhans/Projects/Django/trunk/django/contrib/admin/views/" in add_stage
  254. new_object =
File "/Users/jkocherhans/Projects/Django/trunk/django/db/models/" in save
  141. obj_list = expanded_data[related.var_name].items()

  KeyError at /monitor/bereavement/monitoringreport/add/

Attachments (1)

num_in_admin_0.diff (672 bytes) - added by jkocherhans 12 years ago.

Download all attachments as: .zip

Change History (4)

Changed 12 years ago by jkocherhans

Attachment: num_in_admin_0.diff added

comment:1 Changed 12 years ago by Malcolm Tredinnick

Does it make sense to apply this without also allowing the same thing for num_extra_on_change? That is the "change" equivalent of the add form's num_in_admin setting.

comment:2 Changed 12 years ago by jkocherhans

num_extra_on_change is covered by this patch. The code change is to AutomaticManipulator's save method, so it covers both the add and edit case where no form data is received for edit_inline objects.

comment:3 Changed 12 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [3546]) Fixed #2484 -- Handle num_in_admin and num_extra_on_change being 0 for the
admin interface. Thanks, Joseph Kocherhans.

Note: See TracTickets for help on using tickets.
Back to Top