如何使用Wagtail设置View的URL?

问题描述 投票:0回答:1

Watail是否只在Promote Tab中使用子弹,还是应该在urls.py?

我正在使用Wa,我有2页:

a)国际部长事务部>b)Doctrina Elim

我想将a

设置为主页,并且将[[b设置为:http://127.0.0.1:8000/doctrina-elim/

enter image description here

现在doctrina/urls.py为空:(

我在doctrina/models.py中有这个模型:

class DoctrinaIndexPage(Page): template = 'doctrina/doctrina_index_page.html' nivel = models.CharField(max_length=255, default='Básico') subtitle = models.CharField(max_length=255, default='Publicación reciente') body = RichTextField(blank=True) content_panels = Page.content_panels + [ FieldPanel('subtitle', classname="full"), FieldPanel('body', classname="full") ]

视图具有此(doctrina / views.py)

from django.shortcuts import render # Create your views here. def home_page(response): return render(response, "home/home_page.html") # Create your views here. def doctrina_index_page(response): return render(response, "doctrina/doctrina_index_page.html")
promote tab中,它具有以下网址:

doctrina-elim

但是在主机名后输入404,为什么?

enter image description here

结构:

-doctrina |__pycache.py_ |__migrations.py |__templates |___init__.py |_admin.py |_apps.py |_models.py |_test.py |_urls.py |_views.py -elim |__pycache_.py |_settings.py |_static |_templates |___init__.py |_urls.py |_wsgi.py -home |__pycache_.py |_migrations.py |_static |_templates \ home |_home_page.html |_welcome_page.html |___init__.py |_models.py |_urls.py |_views.py

我只能将我的Page模型设置为网站,然后访问“ /”主页。

Wagtail是否仅在Promote Tab中使用子弹,还是应该在urls.py中设置url?我正在使用Wagtail,共有2页:a)部长Elim部长b)博士Elim我想将a设置为...

django wagtail
1个回答
0
投票
使用Wagtail,您可能会发现views.py文件中没有太多内容。相反,您可以创建链接以导航到页面,然后Wagtail为页面提供服务-您无需像从操作中那样从视图中渲染它。这是一些如何呈现导航栏的示例代码:
© www.soinside.com 2019 - 2024. All rights reserved.