关于django:’WizardStep2Form’没有名为’language_code’的字段。 在Djangocms aldryn_newsblog中

'WizardStep2Form' has no field named 'language_code'. in Djangocms aldryn_newsblog

我已经成功安装了aldryn_newsblog。我正在使用djangocms。
每次我尝试创建一个新的新闻/博客文章。我收到一个错误

1
2
    ValueError at /cms_wizard/create/
'WizardStep2Form' has no field named 'language_code'.

这是我的settings.py文件INSTALLED_APPS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    #  Aldryn News & Blog
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_common',
'aldryn_newsblog',
'aldryn_people',
'aldryn_reversion',
'aldryn_translation_tools',
#'djangocms_text_ckeditor',
#'easy_thumbnails',
#'filer',
'parler',
#'reversion',
'sortedm2m',
'taggit',
'absolute',
'aldryn_forms',
'aldryn_forms.contrib.email_notifications',
'captcha',
'emailit',
#  Aldryn News & Blog

这是完整的追溯

1
Traceback:

在get_response中输入文件"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
132. response = wrapped_callback(request,* callback_args,** callback_kwargs)
文件"/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py"在视图中
71. return self.dispatch(request,* args,** kwargs)
内部的文件"/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
145. return func(* args,** kwargs)
发送文件"/usr/local/lib/python2.7/dist-packages/cms/wizards/views.py"
38.请求,* args,** kwargs)
发送文件"/usr/local/lib/python2.7/dist-packages/formtools/wizard/views.py"
237. response = super(WizardView,self).dispatch(request,* args,** kwargs)
发送文件"/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py"
89.返回处理程序(request,* args,** kwargs)
在帖子中记录"/usr/local/lib/python2.7/dist-packages/formtools/wizard/views.py"
290.如果form.is_valid():
is_valid中的文件"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py"
184.返回self.is_bound而不是self.errors
文件"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py"错误
176. self.full_clean()
在full_clean中输入文件"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py"
394. self._post_clean()
_post_clean中的文件"/usr/local/lib/python2.7/dist-packages/parler/forms.py"
83. self.save_translated_fields()
在save_translated_fields中输入文件"/usr/local/lib/python2.7/dist-packages/parler/forms.py"
110. self._clean_translation_model(translation_model,exclude)
_clean_translation_model中的文件"/usr/local/lib/python2.7/dist-packages/parler/forms.py"
125. self._update_errors(e)
_update_errors中的文件"/usr/local/lib/python2.7/dist-packages/django/forms/models.py"
402. self.add_error(无,错误)
add_error中的文件"/usr/local/lib/python2.7/dist-packages/django/forms/forms.py"
360."'%s'没有名为'%s'的字段。" %(self.class.name,field))

异常类型:ValueError at / cms_wizard / create /
异常值:'WizardStep2Form'没有名为'language_code'的字段。

请帮助


我刚遇到类似的问题:
'ArticleForm' has no field named 'language_code'.

原来是与最新版本的django-parler发生冲突(请参阅此处的更改日志)。

Note: django-parler models now mandate that a language code is selected; either by calling model.set_current_language(), Model.objects.language() or activating a gettext environment. The latter always happens in a standard web request, but needs to happen explicitly in management commands. This avoids hard to debug situations where unwanted model changes happen on implicitly selected languages.

要快速解决问题,请尝试运行pip uninstall django-parler然后再运行pip install django-parler==1.6.2(或者在requirements.txt文件中固定版本(如果有的话))。

如果您能够更新django,django CMS和其他依赖项的版本,那么它们也可以正常工作(并且不限制您使用旧版本的django-parler)