@login_required
def view_architect_page(request): args = {'user': request.user} return render(request, 'DEMOAPP/architect_page.html', args)
这是我的看法。它将我重定向到我的登录页面,然后允许我在登录后进入该页面,但它不显示摇摆信息。我知道它不起作用,因为当我在wagtail中“查看实况”时,文件会显示出来
下面是我的模型.py
class ArchitectPage(Page):
search_fields = Page.search_fields + [
] # these are if adding a search to the website
# content tab panels
content_panels = Page.content_panels + [ MultiFieldPanel( [InlinePanel('architect_pdf', max_num=20, min_num=0, label="architect pdf")], heading="architect pdf" ), ]
# what to call the panels on wagtail
edit_handler = TabbedInterface([ ObjectList(content_panels, heading='Content'), ObjectList(Page.promote_panels, heading='SEO'), ObjectList(Page.settings_panels, heading='Settings', classname='settings'),
classname settings adds the cog
])
class ArchitectDownloads(Orderable):
page = ParentalKey(ArchitectPage, on_delete=models.CASCADE, related_name='architect_pdf')
architect_pdf = models.ForeignKey(
'wagtaildocs.Document', null=True, blank=True, on_delete=models.SET_NULL, related_name='+' )
panels = [
DocumentChooserPanel('architect_pdf'),
]
这是我的html,由于这个登录必需的视图,所以没有显示
<ul>
{% for download in page.architect_pdf.all %} {# loop over the ArchitectDownload objects #}
{% with doc=download.architect_pdf %} {# retrieve the Document object for each one #}
<li><a href="{{ doc.url }}">{{ doc.title }}</a></li>
{% endwith %}
{% endfor %}
</ul>
我一直在评论这个网址,可以看到视图是一个问题
path('architect-page/', views.view_architect_page),
有没有人知道我以后如何才能在models.py中使用wagtail类声明来创建视图
目前没有回答
相关问题 更多 >
编程相关推荐