Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

MultiValueDictKeyError Issue when using with Streamfields #58

Open
JaredOzzy opened this issue Mar 26, 2019 · 3 comments
Open

MultiValueDictKeyError Issue when using with Streamfields #58

JaredOzzy opened this issue Mar 26, 2019 · 3 comments

Comments

@JaredOzzy
Copy link

JaredOzzy commented Mar 26, 2019

I am getting a strange issue when i am using the condensed inline panel with a orderable that has a field that is used as a streamfield. Everything works until i try to post(save the page with new items), if i use the Normal InlinePanal it works, if i convert back to condensed inlinepanel it also works, until i add an item again.
Im using:

wagtail>=2.1,<2.2
wagtail-condensedinlinepanel==0.5.2

models

class DownloadDocPage(Page):
    content_panels = Page.content_panels + [
        MultiFieldPanel(
            [
                CondensedInlinePanel('operating_systems'),
            ],
            heading="Operating Systems",
            classname="collapsible"
        ),
        MultiFieldPanel(
            [
                CondensedInlinePanel('apis'),
            ],
            heading="Application Programming Interfaces",
            classname="collapsible"
        ),
    ]
    parent_page_types = ['HomePage']

class OperatingSystems(Orderable):
    page = ParentalKey(DownloadDocPage, related_name='operating_systems')
    operating_system = models.CharField(max_length=255)
    characterless_id = models.CharField(max_length=30, help_text='This should be a unique lower-case ID with no special characters, for example Unix-Like would be unixlike')
    text = StreamField(blocks.TextStreamBlock())

    panels = [
        FieldPanel('operating_system'),
        FieldPanel('characterless_id'),
        StreamFieldPanel('text'),
    ]

    def __str__(self):
        return u'{}'.format(self.operating_system)

blocks.py

class TextStreamBlock(StreamBlock):
    richtext = RichTextBlock()
    text = TextBlock()

traceback

Environment:


Request Method: POST
Request URL: http://localhost/cms/pages/56/edit/

Django Version: 1.11.20
Python Version: 3.6.8
Installed Applications:
['django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django_countries',
 'user',
 'app',
 'pipeline',
 'minio_storage',
 'modelcluster',
 'taggit',
 'honeypot',
 'djcelery_email',
 'heartbeat',
 'constance.backends.database',
 'django.contrib.auth',
 'wagtail.contrib.modeladmin',
 'wagtail.contrib.forms',
 'wagtail.contrib.redirects',
 'wagtail.embeds',
 'wagtail.sites',
 'wagtail.users',
 'wagtail.snippets',
 'wagtail.documents',
 'wagtail.images',
 'wagtail.search',
 'wagtail.admin',
 'wagtail.core',
 'wagtailfontawesome',
 'condensedinlinepanel',
 'allauth',
 'allauth.account',
 'allauth.socialaccount']
Installed Middleware:
['django.middleware.cache.UpdateCacheMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'htmlmin.middleware.HtmlMinifyMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'wagtail.core.middleware.SiteMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware',
 'django.middleware.cache.FetchFromCacheMiddleware',
 'htmlmin.middleware.MarkRequestMiddleware']



Traceback:

File "/usr/local/lib/python3.6/site-packages/django/utils/datastructures.py" in __getitem__
  83.             list_ = super(MultiValueDict, self).__getitem__(key)

During handling of the above exception ('operating_systems-0-text-count'), another exception occurred:

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.6/site-packages/django/views/decorators/cache.py" in _cache_controlled
  43.             response = viewfunc(request, *args, **kw)

File "/usr/local/lib/python3.6/site-packages/wagtail/admin/urls/__init__.py" in wrapper
  102.             return view_func(request, *args, **kwargs)

File "/usr/local/lib/python3.6/site-packages/wagtail/admin/decorators.py" in decorated_view
  34.             return view_func(request, *args, **kwargs)

File "/usr/local/lib/python3.6/site-packages/wagtail/admin/views/pages.py" in edit
  339.         if form.is_valid() and not page.locked:

File "/usr/local/lib/python3.6/site-packages/modelcluster/forms.py" in is_valid
  309.         formsets_are_valid = all([formset.is_valid() for formset in self.formsets.values()])

File "/usr/local/lib/python3.6/site-packages/modelcluster/forms.py" in <listcomp>
  309.         formsets_are_valid = all([formset.is_valid() for formset in self.formsets.values()])

File "/usr/local/lib/python3.6/site-packages/django/forms/formsets.py" in is_valid
  321.         self.errors

File "/usr/local/lib/python3.6/site-packages/django/forms/formsets.py" in errors
  295.             self.full_clean()

File "/usr/local/lib/python3.6/site-packages/django/forms/formsets.py" in full_clean
  346.             if not form.has_changed() and i >= self.initial_form_count():

File "/usr/local/lib/python3.6/site-packages/django/forms/forms.py" in has_changed
  439.         return bool(self.changed_data)

File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py" in __get__
  35.         res = instance.__dict__[self.name] = self.func(instance)

File "/usr/local/lib/python3.6/site-packages/django/forms/forms.py" in changed_data
  446.             data_value = field.widget.value_from_datadict(self.data, self.files, prefixed_name)

File "/usr/local/lib/python3.6/site-packages/wagtail/core/blocks/base.py" in value_from_datadict
  512.         return self.block_def.value_from_datadict(data, files, name)

File "/usr/local/lib/python3.6/site-packages/wagtail/core/blocks/stream_block.py" in value_from_datadict
  152.         count = int(data['%s-count' % prefix])

File "/usr/local/lib/python3.6/site-packages/django/utils/datastructures.py" in __getitem__
  85.             raise MultiValueDictKeyError(repr(key))

Exception Type: MultiValueDictKeyError at /cms/pages/56/edit/
Exception Value: "'operating_systems-0-text-count'"
```
`
@abadez
Copy link

abadez commented May 28, 2020

I'm having the same problem

@JaredOzzy
Copy link
Author

@abadez

I believe i stopped using the condensedInlinePanel because of this issue, there wasn't a workaround for me.

@crukundo
Copy link

What's the status on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants