Thursday, September 24, 2015

Admin issues with inlines


I have an issue with the admin and inlines for related models. When hitting save on a model editing page I get this traceback:

Traceback (most recent call last):
File "lib/python2.7/site-packages/django/core/handlers/", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/", line 616, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "lib/python2.7/site-packages/django/utils/", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/views/decorators/", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/", line 233, in inner
return view(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/", line 1519, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "lib/python2.7/site-packages/django/utils/", line 34, in _wrapper
return bound_func(*args, **kwargs)
File "lib/python2.7/site-packages/django/utils/", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/utils/", line 30, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "lib/python2.7/site-packages/django/utils/", line 145, in inner
return func(*args, **kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/", line 1466, in changeform_view
if all_valid(formsets) and form_validated:
File "lib/python2.7/site-packages/django/forms/", line 439, in all_valid
if not formset.is_valid():
File "lib/python2.7/site-packages/django/forms/", line 304, in is_valid
File "lib/python2.7/site-packages/django/forms/", line 278, in errors
File "lib/python2.7/site-packages/django/forms/", line 325, in full_clean
for i in range(0, self.total_form_count()):
File "lib/python2.7/site-packages/django/forms/", line 115, in total_form_count
return min(self.management_form.cleaned_data[TOTAL_FORM_COUNT], self.absolute_max)
File "lib/python2.7/site-packages/django/forms/", line 97, in management_form
ValidationError: [u'I dati del ManagementForm sono mancanti oppure sono stati manomessi']

The error message in Italian reads "ManagementForm data is missing or has been tampered with".

I also noticed the POST request contains an extra part with __prefix__ in names and empty id which looks suspicious:
Content-Disposition: form-data; name="csrfmiddlewaretoken"

Content-Disposition: form-data; name="model_set-TOTAL_FORMS"

Content-Disposition: form-data; name="model_set-INITIAL_FORMS"

Content-Disposition: form-data; name="model_set-MIN_NUM_FORMS"

Content-Disposition: form-data; name="model_set-MAX_NUM_FORMS"

Content-Disposition: form-data; name="model_set-0-id"

Content-Disposition: form-data; name="model_set-0-property"



Content-Disposition: form-data; name="model_set-40-id"

Content-Disposition: form-data; name="model_set-40-property"

Content-Disposition: form-data; name="model_set-__prefix__-id"

Content-Disposition: form-data; name="model_set-__prefix__-property"

Content-Disposition: form-data; name="_save"


A stack overflow post (
suggests display: none is not picked up from forms.css (empty-form class) but in my case it seems it is. I'm looking at Chrome Developer Tools.

My inlines are defined as:

class Inline(admin.TabularInline):
model = Model
show_change_link = True
can_delete = False
extra = 0
fields = ['property1', 'property2']
readonly_fields = ['property1', 'property2']


Luca Corti

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment