概要
WagtailというDjango製のCMSを使って、自分のホームページを作成しようとしています。
で、CharacterPageモデルを定義してマイグレーションを行おうとしていたのですが、 python manage.py makemigrations
を実行したところ、以下のようなエラーが出て先に進めない状態です。
(huidetang) ~/huidetang ❯❯❯ python manage.py makemigrations master ✱ Traceback (most recent call last): File "manage.py", line 13, in <module> execute_from_command_line(sys.argv) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/management/__init__.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **cmd_options) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/management/base.py", line 332, in execute self.check() File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/management/base.py", line 364, in check include_deployment_checks=include_deployment_checks, File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/management/base.py", line 351, in _run_checks return checks.run_checks(**kwargs) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/core/checks/registry.py", line 73, in run_checks new_errors = check(app_configs=app_configs) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/checks.py", line 62, in get_form_class_check edit_handler = cls.get_edit_handler() File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/utils/decorators.py", line 53, in __call__ return self.value File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/django/utils/functional.py", line 36, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/utils/decorators.py", line 49, in value return self.fn(self.cls) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 804, in get_edit_handler return edit_handler.bind_to_model(cls) File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 131, in bind_to_model new.on_model_bound() File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 280, in on_model_bound for child in self.children] File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 280, in <listcomp> for child in self.children] File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 131, in bind_to_model new.on_model_bound() File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 280, in on_model_bound for child in self.children] File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 280, in <listcomp> for child in self.children] File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 131, in bind_to_model new.on_model_bound() File "/Users/yusuketakakura/.local/share/virtualenvs/huidetang-mAfcCUBe/lib/python3.7/site-packages/wagtail/admin/edit_handlers.py", line 690, in on_model_bound self.related = manager.rel AttributeError: 'DeferredAttribute' object has no attribute 'rel'
なお、追加しようとしている CharacterPage
のモデルは以下の通りです。
from django.db import models from django.http import JsonResponse from wagtail.core.models import Page from wagtail.admin.edit_handlers import InlinePanel from wagtail.images.edit_handlers import ImageChooserPanel from wagtailmarkdown.edit_handlers import MarkdownPanel from wagtailmarkdown.fields import MarkdownField class CharacterPage(Page): """A page of character list.""" character_name = models.CharField(max_length=20) character_image = models.ForeignKey( 'wagtailimages.Image', null=True, blank=True, on_delete=models.SET_NULL, related_name='+', ) character_introduction = MarkdownField() character_from = models.CharField(max_length=20) character_page_url = models.CharField(max_length=255) content_panels = Page.content_panels + [ InlinePanel('character_name', label='Charactor Name'), ImageChooserPanel('character_image'), MarkdownPanel('character_introduction'), InlinePanel('character_from', label='From'), InlinePanel('character_page_url', label='URL'), ] def serve(self, request): return JsonResponse({ 'characterName': self.character_name, 'characterImage': self.character_image.get_rendition('width-300').url, 'characterIntroduction': self.character_introduction, 'characterFrom': self.character_from, 'characterPageUrl': self.character_page_url, })
おそらく、何らかのオブジェクトに rel
という属性が足りないということを言っているのだと思われますが。
なお、環境は以下の通りです。
- macOS Mojave
- Python 3.7.3
- Django 2.0.13
- Wagtail 2.3
- MariaDB 10.3.3
お手数ですが、よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/30 02:54 編集
2019/03/30 06:20
2019/03/31 07:48