djangohttp-status-code-404django-flatpages

Django Flatpage Giving 404 - But One Flatpage Works


Using Django 1.9, Python 3.4...

Recently I modified my flatpages to take a custom field with the class_prepared approach:

http://docs.djangoproject.com/en/dev/ref/signals/#class-prepared

At this time, I already had one flatpage in the database at the URL /about/. After I implemented the above, I successfully tweaked the new field with data, and everything was working.

But then I added another flatpage at /contact/ with the custom field, just to make sure everything was working, and it's giving a 404.

I first thought that my URLConf wasn't working. So I tested several variations, including the catch all in the Django docs and specific entries like:

url(r'^about/', views.flatpage, {'url': '/about/'}, name='about'),
url(r'^contact/', views.flatpage, {'url': '/contact/'}, name='contact'),

But none of these worked.

I found some references to the SITE_ID being wrong, and I confirmed mine is correct by querying the database, and checking the debugging information.

I also confirmed the data in the database, and the table django_flatpage shows 2 rows for the queries I did.

What am I missing?


Solution

  • I was going to actually delete this post, but then I realized... maybe someone else will have this same problem, and find this answer. I was banging my head against the wall, and I finally figured it out. It's weird, sometimes shortly after I post on SO or another SE board, I figure out what my problem was...

    Anyway, in my ExtendedFlatPageAdmin my fieldset didn't include the sites field. Once I added this, I was able to go back to the Django admin, and resave the flatpage. Then it didn't give a 404.