(Wagtail)字段定义与模型'wagtailimages.Images'的关系,该关系未安装或为抽象

时间:2020-09-16 16:05:24

标签: django database django-models backend wagtail

我在Wagtail / Django上遇到问题。

我有文件app/models/abstract_card_snippet.py,其中包含:

from django.db import models
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.documents.edit_handlers import DocumentChooserPanel

    # Abstract Card Snippet
    class AbstractCardSnippet(models.Model):
        title = models.CharField(max_length=255)
        text = models.CharField(max_length=255, null=True, blank=True)
        url = models.URLField(max_length=255, null=True, blank=True,)
        image = models.ForeignKey(
            'wagtailimages.Images',
            null=True,
            blank=True,
            on_delete=models.SET_NULL,
            related_name='+'
        )
    
        panels = [
            FieldPanel('title'),
            FieldPanel('text'),
            FieldPanel('url'),
            ImageChooserPanel('image'),
        ]
    
        def __str__(self):
            return '{}'.format(self.title)
    
        class Meta:
            abstract = True

然后app/models/generic_card_snippet.py中的是:

from wagtail.snippets.models import register_snippet
from .abstract_card_snippet import AbstractCardSnippet

@register_snippet
class GenericCard(AbstractCardSnippet):
    pass

但是当我运行项目或尝试进行迁移时,会出现此错误:

web_1      | Exception in thread django-main-thread:
web_1      | Traceback (most recent call last):
web_1      |   File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
web_1      |     self.run()
web_1      |   File "/usr/local/lib/python3.6/threading.py", line 864, in run
web_1      |     self._target(*self._args, **self._kwargs)
web_1      |   File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
web_1      |     fn(*args, **kwargs)
web_1      |   File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
web_1      |     self.check(display_num_errors=True)
web_1      |   File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 436, in check
web_1      |     raise SystemCheckError(msg)
web_1      | django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
web_1      |
web_1      | ERRORS:
web_1      | app_snippets.GenericCard.image: (fields.E300) Field defines a relation with model 'wagtailimages.Images', which is either not installed, or is abstract.
web_1      | app_snippets.GenericCard.image: (fields.E307) The field app_snippets.GenericCard.image was declared with a lazy reference to 'wagtailimages.images', but app 'wagtailimages' doesn't provide model 'images'.

对于这个问题我一无所知,找不到与该问题相关的任何东西。

0 个答案:

没有答案
相关问题