Django flatpages and a catchall startpage
I'm using django 1.1 and flatpages. It works pretty well, but I didn't manage to get a catchall or default page running.
As soon as I add a entry to url.py for my startpage, the flatpages aren't displayed anymore.
(r'^', 'myproject.mysite.views.startpage'),
I know flatpages uses a 404 hook, but how do you开发者_JAVA技巧 configure the default website?
I believe this is what you want (with a $
):
(r'^$', 'myproject.mysite.views.startpage')
It should catch only empty requests.
This regex matches everything, so no wonder that flatpages are not working - they are only fallback, activated on 404 error. And with this regex you don't give a chance for 404 error to show.
So, what you want to do is not possible with such regex catchall and flatpages. Personally, if I want to do catch-all, I put all 'normal' URLs above it - but flatpages are not using URLs so...
精彩评论