The same code base in production is giving me the following error in my server logs. The issue seems to be with the zinnia blog app that I use within my Django CMS. What is this error and how do I resolve?
I have reinstall this zinnia and still get the error, strange thing is that the issue does not appear on my local machine using the same database.
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 255, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 178, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 220, in handle_uncaught_exception
if resolver.urlconf_module is None:
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 342, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/srv/project/cherry/cherry/core/urls.py", line 6, in <module>
admin.autodiscover()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 29, in autodiscover
import_module('%s.admin' % app)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/zinnia/admin/__init__.py", line 6, in <module>
from zinnia.admin.entry import EntryAdmin
File "/usr/local/lib/python2.7/dist-packages/zinnia/admin/entry.py", line 25, in <module>
from zinnia.admin.forms import EntryAdminForm
File "/usr/local/lib/python2.7/dist-packages/zinnia/admin/forms.py", line 17, in <module>
class CategoryAdminForm(forms.ModelForm):
File "/usr/local/lib/python2.7/dist-packages/zinnia/admin/forms.py", line 44, in CategoryAdminForm
class Meta:
File "/usr/local/lib/python2.7/dist-packages/zinnia/admin/forms.py", line 49, in Meta
fields = forms.ALL_FIELDS
**AttributeError: 'module' object has no attribute 'ALL_FIELDS'**
File on server from /usr/local/lib/python2.7/dist-packages/zinnia/admin/forms.py:
"""Forms for Zinnia admin"""
from django import forms
from django.db.models import ManyToOneRel
from django.db.models import ManyToManyRel
from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from django.contrib.admin.widgets import RelatedFieldWidgetWrapper
from mptt.forms import TreeNodeChoiceField
from zinnia.models.entry import Entry
from zinnia.models.category import Category
from zinnia.admin.widgets import MPTTFilteredSelectMultiple
from zinnia.admin.fields import MPTTModelMultipleChoiceField
class CategoryAdminForm(forms.ModelForm):
"""
Form for Category's Admin.
"""
parent = TreeNodeChoiceField(
label=_('Parent category'),
level_indicator='|--', required=False,
empty_label=_('No parent category'),
queryset=Category.objects.all())
def __init__(self, *args, **kwargs):
super(CategoryAdminForm, self).__init__(*args, **kwargs)
rel = ManyToOneRel(Category._meta.get_field('tree_id'),
Category, 'id')
self.fields['parent'].widget = RelatedFieldWidgetWrapper(
self.fields['parent'].widget, rel, self.admin_site)
def clean_parent(self):
"""
Check if category parent is not selfish.
"""
data = self.cleaned_data['parent']
if data == self.instance:
raise forms.ValidationError(
_('A category cannot be parent of itself.'))
return data
class Meta:
"""
CategoryAdminForm's Meta.
"""
model = Category
fields = forms.ALL_FIELDS
class EntryAdminForm(forms.ModelForm):
"""
Form for Entry's Admin.
"""
categories = MPTTModelMultipleChoiceField(
label=_('Categories'), required=False,
queryset=Category.objects.all(),
widget=MPTTFilteredSelectMultiple(_('categories'), False,
attrs={'rows': '10'}))
def __init__(self, *args, **kwargs):
super(EntryAdminForm, self).__init__(*args, **kwargs)
rel = ManyToManyRel(Category, 'id')
self.fields['categories'].widget = RelatedFieldWidgetWrapper(
self.fields['categories'].widget, rel, self.admin_site)
self.fields['sites'].initial = [Site.objects.get_current()]
class Meta:
"""
EntryAdminForm's Meta.
"""
model = Entry
fields = forms.ALL_FIELDS
Shell:
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1, 5, 1, 'final', 0)
>>> from django.forms import ALL_FIELDS
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name ALL_FIELDS
>>>
Zinnia v0.14 is not compatible with django 1.5
http://docs.django-blog-zinnia.com/en/latest/notes/compatibility.html