djangodjango-flatpages

Setting flat pages in admin model


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


Solution

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