question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MultiValueDictKeyError: "'body-0-deleted'"

See original GitHub issue

We keep getting this issue:

MultiValueDictKeyError: "'body-0-deleted'"
  File "django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/decorators/cache.py", line 38, in _cache_controlled
    response = viewfunc(request, *args, **kw)
  File "django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "wagtail/wagtailadmin/views/pages.py", line 150, in create
    validate_page_form(form, parent_page)
  File "wagtail/wagtailadmin/views/pages.py", line 311, in validate_page_form
    form.full_clean()
  File "django/forms/forms.py", line 353, in full_clean
    self._clean_fields()
  File "django/forms/forms.py", line 362, in _clean_fields
    value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))
  File "wagtail/wagtailcore/blocks/base.py", line 457, in value_from_datadict
    return self.block_def.value_from_datadict(data, files, name)
  File "wagtail/wagtailcore/blocks/stream_block.py", line 138, in value_from_datadict
    if data['%s-%d-deleted' % (prefix, i)]:
  File "django/utils/datastructures.py", line 319, in __getitem__
    raise MultiValueDictKeyError(repr(key))

Here is the body:

{
action-submit: Submit for moderation, 
author: The Late Show, 
body-count: 1, 
cover_image: 21679, 
csrfmiddlewaretoken: 5h4B0Z7TacaIIPPQDs1LyNuJlJp3o3Iq, 
expire_at: , 
go_live_at: , 
page_relations-INITIAL_FORMS: 0, 
page_relations-MAX_NUM_FORMS: 1000, 
page_relations-MIN_NUM_FORMS: 0, 
page_relations-TOTAL_FORMS: 0, 
search_description: , 
seo_title: , 
slug: dislike-or-not-dislike, 
summary: <p>The rumors are true, Facebook is creating a "Dislike" button.</p>, 
tags: Kriya,Gangiah,FrankieDuToit,TheLateShow,facebook,dislike, 
title: To "Dislike" or not to "Dislike"
}

It seems to be related to this:

http://stackoverflow.com/questions/5895588/django-multivaluedictkeyerror-error-how-do-i-deal-with-it

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gasmancommented, Sep 17, 2015

OK - I think this is caused by the editor using the ‘back’ button while editing. I’ve been able to reproduce it with the following steps (in Chrome):

  • create a new page with a streamfield
  • Add a block to the streamfield
  • Navigate away from the page (e.g. by clicking ‘Images’ in the menu)
  • Use the browser’s back button
  • Submit the form

I don’t think it’s possible to eliminate this entirely - the browser is trying to restore the previous state of the form (including the hidden field that specifies how many blocks there are in the streamfield), but fails because the form HTML changes dynamically during editing. However, this will be mitigated by #475, which discourages users from casually browsing away from the page editor - therefore I’ll close this as a duplicate of #475.

0reactions
tomkinscommented, Aug 3, 2021

We’ve recently had this occur when sharing preview links, hopefully recreatable with #7392.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django MultiValueDictKeyError error, how do I deal with it
I'm trying to save a object to my database, but it's throwing a MultiValueDictKeyError error.
Read more >
MultiValueDictKeyError at /cms/pages/15/edit/ "'row-0-body ...
Resolution: Workaround > Wagtail: MultiValueDictKeyError at ... '1' > row-0-DELETE = '' > row-1-body-count = '1' > row-1-body-0-deleted ...
Read more >
How to solve MultiValueDictKeyError - Google Groups
Hello friends, I don't know why Django is so unstable. Before restarting my computer everything works fine. Django could parse a simple
Read more >
MultiValueDictKeyError at /products/create/ : r/django - Reddit
after clicking on upload button i'm getting multivaluedictkeyerror : here'is my whole error : MultiValueDictKeyError at /products/create…
Read more >
MultiValueDictKeyError at /n - YouTube
MultiValueDictKeyError at /n error solved in DjangoConnect me with Blog-www.javaatpoint.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found