【发布时间】:2017-03-23 18:04:08
【问题描述】:
我已经成功地设置了本教程的开发服务器:
http://docs.wagtail.io/en/v1.9/getting_started/tutorial.html
我目前正处于“在blog/templates/blog/blog_page.html: 创建模板”这一步,并且我能够创建进入主页/博客/博客帖子但它们没有在主页/博客中列出的子页面他们在教程中做。我不知道为什么,我尝试通过将博客文章作为博客文章放置在主页/博客中来改变博客文章的显示位置,但仍然没有。
我想我不明白这里需要做什么:
from django.db import models
from wagtail.wagtailcore.models import Page
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailsearch import index
# Keep the definition of BlogIndexPage, and add:
class BlogPage(Page):
date = models.DateField("Post date")
intro = models.CharField(max_length=250)
body = RichTextField(blank=True)
search_fields = Page.search_fields + [
index.SearchField('intro'),
index.SearchField('body'),
]
content_panels = Page.content_panels + [
FieldPanel('date'),
FieldPanel('intro'),
FieldPanel('body', classname="full"),
]
更具体地说,# Keep the definition of BlogIndexPage, and add:。
感谢您的帮助!
【问题讨论】:
-
Keep the definition of BlogIndexPage, and add表示BlogIndexPage的实现(类)在代码 sn-p 中没有重复,以便清楚起见(因此您专注于引入的新BlogPage类)和空间,但您应该将BlogIndexPage类定义保留在文件中。换句话说,models.py应该包含BlogIndexPage和BlogPage类(以及所有导入)。编辑:如果这已经是您所拥有的,请分享您的blog/models.py和blog/templates/blog/blog_index_page.html的全部内容。 -
@LoïcTeixeira 我相信我有。这是models.py > pastebin.com/8hyxezHv / blog_index_page.html > pastebin.com/VrhPxg8V