开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜