django-nested-inlines
django-nested-inlines copied to clipboard
MultiValueDictKeyError in Django 1.6
After upgrading to Django 1.6 I get a "MultiValueDictKeyError" after trying to add or delete a nested-inline object.
This seems to be due to a change in the admin templates in 1.6. See this issue on another project: https://github.com/iambrandontaylor/django-admin-sortable/issues/64 And the commit that fixed it: https://github.com/iambrandontaylor/django-admin-sortable/commit/469e7d5d4dfb4923035b45e01847db52d5cf73ae
Not sure what the problem is exactly, I'm going to dig into the templates now to see if I can fix it as well.
Thanx man!
Alright I seem to have fixed it, at least for me on the project I'm working on. I might make a pull request on SilverFix' repo which generally seems to be more stable and which is the one I am running myself ( https://github.com/silverfix/django-nested-inlines ) but for now you can do this:
- Override the templates
admin/edit_inline/stacked.htmlandadmin/edit_inline/tabular.htmlby copying the contents from the repo (I used the ones from https://github.com/silverfix/django-nested-inlines/tree/master/nested_inlines/templates/admin/edit_inline ) and placing them in your own project. - Look for the line
{% if inline_admin_form.has_auto_field %}{{ inline_admin_form.pk_field.field }}{% endif %} - Replace that line with
{% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %} - Do this for both templates.
Note that, because the templates in Soaa-'s and SilverFix' repo's are based on Django 1.5, you will loose any changes in Django 1.6 for those two templates, but this is the easiest way to solve this for now.
Thanks man, I will try it out. So the SilverFix nested inlines don't have this problem? Should I just install SilverFix's to try it out, do you think I will have problems?
Well like I said I use SilverFix' version because that one is way more active (last update 19 days ago versus 9 months) and generally seems more stable because of some big bugfixes, so yeah, I recommend his version. But his version also has his bug, that's how I ran into it.
Note by the way that there is a visual bug in inlines.js with the "add more" button. This is a div in the inlines.js version of the repo, but in Django 1.6 it has become a proper tr element. You can override inlines.js in the same manor as the templates and alter that to fix that visual bug:
- Look for the line
if ($this.attr("tagName") == "TR") { - Replace it with
if ($this.prop("tagName") == "TR") {
Perfect, I'll give it a go, thanks again.
Ok, I tried it and it worked! Thank you very much Gwildor!