Django HTML Fallback Middleware
For each HTTP request, if no url can handle it, searches for a suitable template (based on request uri) and renders it (similar to flatpage.middleware.FlatpageFallbackMiddleware).
Install
Manual install
git clone https://github.com/lusentis/django-htmlfallbackmiddleware
python setup.py install
easy_install
easy_install django-htmlfallbackmiddleware
Setup
Put htmlfallbackmiddleware.middleware.HTMLFallbackMiddleware
at the end of your settings.MIDDLEWARE_CLASSES
list
MIDDLEWARE_CLASSES = (
...
'htmlfallbackmiddleware.middleware.HTMLFallbackMiddleware',
)
Template name resolution
If no urlpattern
matches the current request url (e.g. /myapp/list
), then:
- if the template
myapp/list.html
exists then render it and stop - if the template
list.html
exists then render it and stop - else raise Http404