Handling 404 Page on FeinCMS

June 5th, 2011

If you add dynamic content such as FeinCMS navigation in your 404 page then you need custom 404 handler.

Create custom views for 404 page.

from django.shortcuts import render_to_response
from django.template import RequestContext
from feincms.module.page.models import Page
 
def page_not_found(request, template_name='404.html'): 
    page = Page.objects.best_match_for_request(request) 
    return render_to_response(template_name, {'feincms_page' : page}, context_instance=RequestContext(request))

In urls.py add the following line :

handler404 = 'cms.views.page_not_found'

That’s it.

Related posts:

  1. Getting Started With Django-CMS
  2. Django Tutorial – Simple Notes Application
  3. A Quick Tutorial on Django MPTT
  4. Receiving Email Using AppEngine and Django
  5. Using django-paypal IPN in Django 1.2

Tags: