Reputation: 658
My Django CMS site is suddenly unable to publish pages or add plugins due to the 'language' not present in the post. I've never seen this issue before and I'm not sure how to fix it. The traceback is below.
Django version 1.4.5
Django CMS version 2.4.2
"Key 'language' not found in <QueryDict: {u'placeholder': [u'1434'], u'plugin_type': [u'TextPlugin']}>"
Request Method: POST
Request URL: http://domain.com/admin/cms/page/495/add-plugin/
Django Version: 1.4.5
Exception Type: MultiValueDictKeyError
Exception Value:
"Key 'language' not found in <QueryDict: {u'placeholder': [u'1434'], u'plugin_type': [u'TextPlugin']}>"
Exception Location: /var/www/.virtualenvs/domain.com/lib/python2.6/site-packages/django/utils/datastructures.py in __getitem__, line 258
Python Executable: /var/www/.virtualenvs/domain.com/bin/python
Python Version: 2.6.6
Python Path:
['/var/www/domain.com/app',
'/var/www/.virtualenvs/domain.com/bin',
'/var/www/.virtualenvs/domain.com/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
'/var/www/.virtualenvs/domain.com/lib/python2.6/site-packages/pip-1.3.1-py2.6.egg',
'/var/www/.virtualenvs/domain.com/src/django-admin-bootstrapped',
'/var/www/.virtualenvs/domain.com/src/johnny-panel',
'/var/www/.virtualenvs/domain.com/lib64/python26.zip',
'/var/www/.virtualenvs/domain.com/lib64/python2.6',
'/var/www/.virtualenvs/domain.com/lib64/python2.6/plat-linux2',
'/var/www/.virtualenvs/domain.com/lib64/python2.6/lib-tk',
'/var/www/.virtualenvs/domain.com/lib64/python2.6/lib-old',
'/var/www/.virtualenvs/domain.com/lib64/python2.6/lib-dynload',
'/usr/lib64/python2.6',
'/usr/lib/python2.6',
'/var/www/.virtualenvs/domain.com/lib/python2.6/site-packages']
/var/www/.virtualenvs/domain.com/lib/python2.6/site-packages/cms/admin/pageadmin.py in add_plugin
language = request.POST['language'] or get_language_from_request(request)
Local Vars
Variable Value
parent
None
self
<cms.admin.pageadmin.PageAdmin object at 0x3b58710>
request
"<WSGIRequest\npath:/admin/cms/page/495/add-plugin/,
GET:<QueryDict: {}>,
POST:<QueryDict: {u'placeholder': [u'1434'], u'plugin_type': [u'TextPlugin']}>,
META:{'CONTENT_LENGTH': '39',
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
'CSRF_COOKIE': 'YmXTWNblNRZix37nd5xINn6Eq0VciynN',
'HTTP_ACCEPT': 'text/html, */*',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
'HTTP_CONNECTION': 'close',
'HTTP_COOKIE': 'djangocms_nodes_open=page_502; CMS_toolbar-collapsed=false;,
'HTTP_HOST': 'domain.com',
'HTTP_ORIGIN': 'http://domain.com',
'HTTP_REFERER': 'http://domain.com/admin/cms/page/495/',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.32 Safari/537.36',
'HTTP_X_CSRFTOKEN': 'YmXTWNblNRZix37nd5xINn6Eq0VciynN',
'HTTP_X_FORWARDED_FOR': '64.21.121.50',
'HTTP_X_REAL_IP': '64.21.121.50',
'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
'PATH_INFO': u'/admin/cms/page/495/add-plugin/',
'QUERY_STRING': '',
'RAW_URI': '/admin/cms/page/495/add-plugin/',
'REMOTE_ADDR': '64.21.121.50',
'REMOTE_PORT': '80',
'REQUEST_METHOD': 'POST',
'SCRIPT_NAME': u'',
'SERVER_NAME': 'domain.com',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.0',
'SERVER_SOFTWARE': 'gunicorn/0.17.2',
'gunicorn.socket': <socket._socketobject object at 0x210b980>,
'wsgi.errors': <gunicorn.glogging.LazyWriter object at 0x1b068d0>,
'wsgi.file_wrapper': <class gunicorn.http.wsgi.FileWrapper at 0x1bd3ef0>,
'wsgi.input': <gunicorn.http.body.Body object at 0x21346d0>,
'wsgi.multiprocess': True,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>"
parent_id
None
placeholder_id
u'1434'
placeholder
<Placeholder: main-content>
page
<cms.models.pagemodel.Page object at 0x4192210>
plugin_type
u'TextPlugin'
/var/www/.virtualenvs/domain.com/lib/python2.6/site-packages/django/utils/datastructures.py in __getitem__
raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))
Local Vars
Variable Value
self
<QueryDict: {u'placeholder': [u'1434'], u'plugin_type': [u'TextPlugin']}>
key
'language'
UPDATE:
Language settings straight from the python shell:
settings.LANGUAGES
[('en', 'English')]
settings.LANGUAGE_CODE
'en'
settings.LANGUAGE_COOKIE_NAME
'django_language'
settings.DEFAULT_LANGUAGE
0
settings.USE_I18N
False
settings.USE_L10N
False
Upvotes: 1
Views: 1057
Reputation: 658
There is an issue with django cms that throws an error when 'languages' is not present in the POST data; a MultiValueDictKeyError error.
As of this writing, there is an open pull request for a fix from @blackrobot. https://github.com/divio/django-cms/pull/2151
If you need the fix before it's integrated into the master branch and released, you can fork this pull or edit your local copy. Edit line 1130 of
cms/admin/pageadmin.py
to become
language = request.POST.get('language') or get_language_from_request(request)
Upvotes: 1