cw.
cw.

Reputation: 63

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 configure the default website?

Upvotes: 0

Views: 607

Answers (2)

Tomasz Zieliński
Tomasz Zieliński

Reputation: 16346

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...

Upvotes: 2

Olivier Verdier
Olivier Verdier

Reputation: 49146

I believe this is what you want (with a $):

(r'^$', 'myproject.mysite.views.startpage')

It should catch only empty requests.

Upvotes: 4

Related Questions