开发者

Do i need to add URLs for flat pages in url.py in django

开发者 https://www.devze.com 2023-03-17 04:26 出处:网络
I have enabled flat pages in django and created page with url /pages/about so i want to know that do i need to create some url in url.py or not

I have enabled flat pages in django

and created page with url /pages/about

so i want to know that do i need to create some url in url.py or not

Because when i 开发者_Go百科try http://ip:8000/pages/about it say page not found

Also when i created page it asked me to select site but iam only using ipaddress, can that be the reason


No, you don't need to add any urls. The Flatpages middleware kicks in when all of your defined urls fail. There's more info in the docs describing how it works.


https://docs.djangoproject.com/en/dev/ref/contrib/flatpages/

and especially this part of the guide shows how you have to configure your urls to use your flatpages


Include this single line code in your root urls.py file

url(r'^pages/', include('django.contrib.flatpages.urls')),

and create flat page file with simple url /about/

Done!!

It works for me

0

精彩评论

暂无评论...
验证码 换一张
取 消