0

I just installed flat pages app for django and trying to create a flat pages from admin . enter image description here

So after I create a page in admin there is an option view on site and when I click on it I am getting Page not found

what am I missing?When I set my name to /pages/overview/ I still get page not found

enter image description here

Ilya Bibik
  • 3,924
  • 4
  • 23
  • 48

1 Answers1

1

You have configured the pages URLs with a prefix of ^pages/, which means you need to add that prefix to your request URL. E.g., for a page that you have configured as /help/overview/, you would access it from http://localhost:8000/pages/help/overview/.

You either need to request all your page URLs with a /pages/ prefix, or use one of the other methods described in the documentation:

You can also set it up as a “catchall” pattern. In this case, it is important to place the pattern at the end of the other urlpatterns:

from django.contrib.flatpages import views

# Your other patterns here
urlpatterns += [
    url(r'^(?P<url>.*/)$', views.flatpage),
]

Another common setup is to use flat pages for a limited set of known pages and to hard code the urls, so you can reference them with the url template tag:

urlpatterns += [
    url(r'^about-us/$', views.flatpage, {'url': '/about-us/'}, name='about'),
    url(r'^license/$', views.flatpage, {'url': '/license/'}, name='license'),
]

Finally you can also use the FlatPageFallbackMiddleware.

Community
  • 1
  • 1
solarissmoke
  • 30,039
  • 14
  • 71
  • 73
  • Thank you @solarissmoke the thing is when I input in a form url with pages I get an error - No FlatPage matches the given query. – Ilya Bibik Jul 17 '16 at 14:29
  • I've edited the answer to clarify. If you save the page with a URL of `/help/overview/`, then you can access it at `http://localhost:8000/pages/help/overview/`. Don't change the URL on the page itself. – solarissmoke Jul 17 '16 at 14:48