开发者

How can I make my root a flatpage in Django

开发者 https://www.devze.com 2023-03-12 20:32 出处:网络
I\'m so sorry if this is obvious. I\'ve created a flatpage with a URL of \\. I\'ve created a catchall (r\'\', include(\'django.contrib.flatpages.urls\')), per \'Practical Django Projects\'p17. I get

I'm so sorry if this is obvious.

I've created a flatpage with a URL of \. I've created a catchall (r'', include('django.contrib.flatpages.urls')), per 'Practical Django Projects' p17. I get an infinite loop.

I can't see this anywhere I search: how do I make the root开发者_C百科 index.html a flatpage?

Thank you


As mentioned by @Richard, include

FlatPageFallBackMiddleware

as part of your classes. I did not know how to do this but was able to find this howto.

The important thing being removing:

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

from your urls.py and including:

'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',

in your settings.py as part of the MIDDLEWARE_CLASSES.


Well, fixed it. This conversation suggests removing

(r'', include('django.contrib.flatpages.urls'))

and keeping (or, in my case, adding!)

FlatpageFallbackMiddleware.

Now I have a root flatpage.

0

精彩评论

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