flatpages issues

4 views
Skip to first unread message

John-Scott

unread,
Jul 13, 2007, 3:51:31 PM7/13/07
to Django users
hi gang,

I'm trying out the flatpages app but not having a great deal of
success. I've followed the instructions at http://www.djangoproject.com/documentation/flatpages/.
I've added a directory in my templates folder (templates/flatpages/
default.html) according to the example in the documentation. I used
the admin interface to make a dummy page 'about' with a URL value of '/
about/' and my site selected for the page. However, when I try to
access the url (mysite.com/about/) I get an error saying that it tried
using the url patterns in urls.py but "The current URL, about/, didn't
match any of these." (I have DEBUG = True in settings.py). If I add:

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

to the urls.py, then I get an error saying "No FlatPage matches the
given query." What am I doing wrong? From the official documentation
it seems that I shouldn't have to add anything to urls.py, since
that's the whole point: flatpages catches the 404 error for url
patterns not found in urls.py then checks if there is a match in the
database and render the result or else re-raises the 404.

Thanks,

j-s

Jacob Kaplan-Moss

unread,
Jul 13, 2007, 4:16:39 PM7/13/07
to django...@googlegroups.com
Hi John-Scott --

Did you add 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
to your ``MIDDLEWARE_CLASSES`` setting?

Jacob

John-Scott Atlakson

unread,
Jul 13, 2007, 4:24:03 PM7/13/07
to django...@googlegroups.com
Yes sir. I followed the examples in the official docs literally and in order (http://www.djangoproject.com/documentation/flatpages/#installation steps 1-3). That worked fine and I was able to immediately start creating flatpages via the admin interface. But I cannot view flatpages on the site. I only added the line to urls.py because I saw some other example somewhere with the catch-all-else pattern but this did seem to at least get me one step closer. Without the urls.py addition, flatpages does not seem to be invoked to handle the 404 at all.

Cheers,
j-s

John-Scott

unread,
Jul 16, 2007, 11:18:43 AM7/16/07
to Django users
Can someone in the know confirm or deny that adding the catch-all line
to urls.py is in fact required to invoke flatpages? I checked out the
source for djangoproject.com and it has this as the last item in
urlpatterns:

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

If this is required, should I file a ticket on the documentation to
get this included in the instructions?

Thanks.

j-s

Jacob Kaplan-Moss

unread,
Jul 16, 2007, 12:24:16 PM7/16/07
to django...@googlegroups.com
On 7/16/07, John-Scott <john.scot...@gmail.com> wrote:
> Can someone in the know confirm or deny that adding the catch-all line
> to urls.py is in fact required to invoke flatpages?

No, it's not; the fallback middleware works fine for me. If it's not
working for you, chances are you've got something misconfigured; why
don't you post your settings.py and we'll take a look?

Jacob

John-Scott Atlakson

unread,
Jul 16, 2007, 1:10:05 PM7/16/07
to django...@googlegroups.com
Ah ha! I just looked through my settings.py file and noticed the setting: SITE_ID = 1
I decided to double check the raw data for the django_sites table and my site id is '2'. (I think id 1 used to be ' example.com' but I had deleted it instead of renaming it, thus creating a mismatch with SITE_ID). Once I changed the SITE_ID value everything started working. I deleted the item from urlpatterns, and you're right, it's unnecessary. Thanks for attempting to get me sorted out.

Cheers,
John-Scott.
Reply all
Reply to author
Forward
0 new messages