1๐
โ
I would write a view that handles adding the .html
and configure a URLConf to use it.
The view
from django.conf import settings
from django.contrib.staticfiles.views import serve
def serve_html(request, file_name):
if not file_name:
file_name = 'index'
file_path = '{}.html'.format(file_name)
# Use Django staticfiles's serve view.
return serve(request, file_path)
The URLConf
url(r'^(?P<file_name>.*)$', serve_html)
It is important to put the URLConf last in your urls.py
otherwise, it will catch all requests and your other URLConfs will not be reached.
๐คaumo
Source:stackexchange.com