【发布时间】:2017-02-02 21:00:47
【问题描述】:
我对 Django Wagtail 比较陌生,我正在关注 docs.wagtail.io 网站上的演示,该网站可以在 here 找到,了解如何使用带有相关链接的 InlinePanel 将链接列表添加到页面 我似乎遇到了一个我不完全理解它的含义的错误。 错误说
AttributeError: type object 'BookPageRelatedLinks' has no attribute 'rel'
演示代码如下
from wagtail.wagtailcore.models import Orderable, Page
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import FieldPanel,InlinePanel
from django.db import models
class BookPage(Page):
# The abstract model for related links, complete with panels
class RelatedLink(models.Model):
title = models.CharField(max_length=255)
link_external = models.URLField("External link", blank=True)
panels = [
FieldPanel('title'),
FieldPanel('link_external'),
]
class Meta:
abstract = True
# The real model which combines the abstract model, an
# Orderable helper class, and what amounts to a ForeignKey link
# to the model we want to add related links to (BookPage)
class BookPageRelatedLinks(Orderable, RelatedLink):
page = ParentalKey('demo.BookPage', related_name='related_links')
content_panels = Page.content_panels + [
InlinePanel('BookPageRelatedLinks', label="Related Links"),
]
我的主要目标是学习这一点,这样我就可以将图像链接添加到我正在开发的 BlogPage 应用程序的侧边栏。
【问题讨论】:
-
您安装了哪些版本的 Django、Wagtail 和
django-modelcluster包? (您可以通过运行pip freeze并查找相关行来查找) -
版本 1.8.1 ,我用
pip install wagtail得到它,我以为它是最新的 -
好的,这就是 Wagtail 的版本 - Django 和
django-modelcluster呢? -
Django==1.10.5django-modelcluster==2.0
标签: wagtail