Hello,
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/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/options.py", line 616, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/sites.py", line 233, in inner
return view(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/options.py", line 1519, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "lib/python2.7/site-packages/django/utils/decorators.py", line 34, in _wrapper
return bound_func(*args, **kwargs)
File "lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "lib/python2.7/site-packages/django/utils/decorators.py", line 30, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "lib/python2.7/site-packages/django/utils/decorators.py", line 145, in inner
return func(*args, **kwargs)
File "lib/python2.7/site-packages/django/contrib/admin/options.py", line 1466, in changeform_view
if all_valid(formsets) and form_validated:
File "lib/python2.7/site-packages/django/forms/formsets.py", line 439, in all_valid
if not formset.is_valid():
File "lib/python2.7/site-packages/django/forms/formsets.py", line 304, in is_valid
self.errors
File "lib/python2.7/site-packages/django/forms/formsets.py", line 278, in errors
self.full_clean()
File "lib/python2.7/site-packages/django/forms/formsets.py", line 325, in full_clean
for i in range(0, self.total_form_count()):
File "lib/python2.7/site-packages/django/forms/formsets.py", 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/formsets.py", line 97, in management_form
code='missing_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:
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="csrfmiddlewaretoken"
0123456789abcdef
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-TOTAL_FORMS"
41
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-INITIAL_FORMS"
41
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-MIN_NUM_FORMS"
0
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-MAX_NUM_FORMS"
1000
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-0-id"
405718
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-0-property"
87462
[...]
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-40-id"
462250
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-40-property"
87462
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-__prefix__-id"
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="model_set-__prefix__-property"
87462
------WebKitFormBoundaryHni3TflxO2xxoMnc
Content-Disposition: form-data; name="_save"
Salva
------WebKitFormBoundaryHni3TflxO2xxoMnc--
A stack overflow post (http://stackoverflow.com/questions/11546245/django-inline-admin-formset-extra-entry-has-prefix-instead-of-number)
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']
thanks
--
Luca Corti
luca@fantacast.it
--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ECE83BE6-226F-49B2-8A90-0010BF66E352%40fantacast.it.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment