wagtail.contrib.forms.models中的循环导入错误

时间:2020-10-26 19:20:53

标签: python django django-forms wagtail

在提交之前,我想确保这是一个错误,而不是我配置不正确的错误。我正在将网站从Wagtail 2.5更新为Wagtail 2.10.2,似乎已经触发了以前工作代码的循环导入。

导入如下:

from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField, StreamField
from wagtail.admin.edit_handlers import FieldPanel, FieldRowPanel, MultiFieldPanel, \
    InlinePanel, PageChooserPanel, StreamFieldPanel, TabbedInterface, ObjectList
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.documents import get_document_model
from wagtail.documents.edit_handlers import DocumentChooserPanel
from wagtail.snippets.models import register_snippet

from wagtail.search import index
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.contrib.forms.models import AbstractForm, AbstractFormField, AbstractFormSubmission
from wagtail.contrib.forms.edit_handlers import FormSubmissionsPanel
from wagtail.contrib.forms.views import SubmissionsListView
from wagtail.contrib.forms.forms import FormBuilder
from wagtail.api import APIField

我得到的错误是:

ImportError: cannot import name 'AbstractForm' from partially initialized module 'wagtail.contrib.forms.models' (most likely due to a circular import)

我很难弄清问题出在哪里,因为它在模块开始时遇到了导入错误。

我尝试做的一件事是改为做from wagtail.contrib.forms import models as form_models然后使用form_models.ModelName,但这也导致AbstractFormField的循环导入错误。但是,这是在实际使用导入时触发的。

不确定从哪里拿走它。欢迎任何疑难解答提示。

0 个答案:

没有答案