Opened 18 years ago

Closed 18 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: dev
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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/base.py" in get_response
  74. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/jkocherhans/Projects/Django/trunk/django/contrib/admin/views/decorators.py" in _checklogin
  55. return view_func(request, *args, **kwargs)
File "/Users/jkocherhans/Projects/Django/trunk/django/views/decorators/cache.py" in _wrapped_view_func
  39. response = view_func(request, *args, **kwargs)
File "/Users/jkocherhans/Projects/Django/trunk/django/contrib/admin/views/main.py" in add_stage
  254. new_object = manipulator.save(new_data)
File "/Users/jkocherhans/Projects/Django/trunk/django/db/models/manipulators.py" in save
  141. obj_list = expanded_data[related.var_name].items()

  KeyError at /monitor/bereavement/monitoringreport/add/
  'followupitem'

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

by jkocherhans, 18 years ago

Attachment: num_in_admin_0.diff added

comment:1 by Malcolm Tredinnick, 18 years ago

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 by jkocherhans, 18 years ago

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 by Malcolm Tredinnick, 18 years ago

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