AttributeError:模块'wagtail.wagtailadmin.edit_handlers'没有属性'FieldPanel'

时间:2017-06-21 15:46:54

标签: python django python-3.x docker wagtail

python 3.6 w w 1.11.1 几个小时前,我的wagtail项目停止成功启动。它失败了:

from wagtail.wagtailadmin import edit_handlers

print(dir(edit_handlers))

class Article(Page):
    html = RichTextField()
    content_panels = Page.content_panels + [
        edit_handlers.FieldPanel('html', classname="full"),
        edit_handlers.InlinePanel('gallery', label="Carousel items", classname='ArticleImage'),
    ]

有错误

AttributeError: module 'wagtail.wagtailadmin.edit_handlers' has no attribute 'FieldPanel'

之后我决定确保它不是我的环境错误和配置的docker文件:

FROM python:latest

ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
RUN pip install wagtail
ADD . /code/

在该docker容器未成功启动之后(引发相同的错误)

我根据文档编写了这段代码: http://docs.wagtail.io/en/v1.9/reference/pages/panels.html

如何解决?

感谢名单

UPD 完整日志:(第一行是print(dir(edit_handlers))的输出)

['FieldDoesNotExist', 'ImproperlyConfigured', 'Page', 'RichTextField', 'TaggableManager', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'absolute_import', 'cached_classmethod', 'camelcase_to_underscore', 'compare', 'curry', 'django', 'fields_for_model', 'forms', 'mark_safe', 'math', 're', 'render_to_string', 'resolve_model_string', 'text_type', 'ugettext_lazy', 'unicode_literals', 'widgets']
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f724c05f0d0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/local/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailforms/models.py", line 16, in <module>
    from wagtail.wagtailadmin.edit_handlers import FieldPanel
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 27, in <module>
    from .forms import (  # NOQA
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/forms.py", line 9, in <module>
    from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 22, in <module>
    UserModel = get_user_model()
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 193, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 203, in get_model
    app_config.import_models()
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/code/project/accounts/models.py", line 90, in <module>
    class FavoriteArticle(models.Model):
  File "/code/project/accounts/models.py", line 91, in FavoriteArticle
    from project.blog.models import Article
  File "/code/project/blog/models.py", line 25, in <module>
    class Article(Page):
  File "/code/project/blog/models.py", line 31, in Article
    edit_handlers.FieldPanel('html', classname="full"),
AttributeError: module 'wagtail.wagtailadmin.edit_handlers' has no attribute 'FieldPanel'
['FieldDoesNotExist', 'ImproperlyConfigured', 'Page', 'RichTextField', 'TaggableManager', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'absolute_import', 'cached_classmethod', 'camelcase_to_underscore', 'compare', 'curry', 'django', 'fields_for_model', 'forms', 'mark_safe', 'math', 're', 'render_to_string', 'resolve_model_string', 'text_type', 'ugettext_lazy', 'unicode_literals', 'widgets']
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f90a2e5f0d0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/local/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailforms/models.py", line 16, in <module>
    from wagtail.wagtailadmin.edit_handlers import FieldPanel
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 27, in <module>
    from .forms import (  # NOQA
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/forms.py", line 9, in <module>
    from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 22, in <module>
    UserModel = get_user_model()
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 193, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 203, in get_model
    app_config.import_models()
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/code/project/accounts/models.py", line 90, in <module>
    class FavoriteArticle(models.Model):
  File "/code/project/accounts/models.py", line 91, in FavoriteArticle
    from project.blog.models import Article
  File "/code/project/blog/models.py", line 24, in <module>
    class Article(Page):
  File "/code/project/blog/models.py", line 30, in Article
    edit_handlers.FieldPanel('html', classname="full"),
AttributeError: module 'wagtail.wagtailadmin.edit_handlers' has no attribute 'FieldPanel'
['FieldDoesNotExist', 'ImproperlyConfigured', 'Page', 'RichTextField', 'TaggableManager', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'absolute_import', 'cached_classmethod', 'camelcase_to_underscore', 'compare', 'curry', 'django', 'fields_for_model', 'forms', 'mark_safe', 'math', 're', 'render_to_string', 'resolve_model_string', 'text_type', 'ugettext_lazy', 'unicode_literals', 'widgets']
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fa2b38430d0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/local/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models()
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailforms/models.py", line 16, in <module>
    from wagtail.wagtailadmin.edit_handlers import FieldPanel
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/edit_handlers.py", line 27, in <module>
    from .forms import (  # NOQA
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/forms.py", line 9, in <module>
    from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 22, in <module>
    UserModel = get_user_model()
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 193, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL, require_ready=False)
  File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 203, in get_model
    app_config.import_models()
  File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/code/project/accounts/models.py", line 90, in <module>
    class FavoriteArticle(models.Model):
  File "/code/project/accounts/models.py", line 91, in FavoriteArticle
    from project.blog.models import Article
  File "/code/project/blog/models.py", line 23, in <module>
    class Article(Page):
  File "/code/project/blog/models.py", line 29, in Article
    edit_handlers.FieldPanel('html', classname="full"),
AttributeError: module 'wagtail.wagtailadmin.edit_handlers' has no attribute 'FieldPanel'

0 个答案:

没有答案