diff --git a/djangorestframework/renderers.py b/djangorestframework/renderers.py index bb0f789aa..de9a01ec4 100644 --- a/djangorestframework/renderers.py +++ b/djangorestframework/renderers.py @@ -373,7 +373,7 @@ class DocumentingHTMLRenderer(DocumentingTemplateRenderer): media_type = 'text/html' format = 'html' - template = 'renderer.html' + template = 'djangorestframework/api.html' class DocumentingXHTMLRenderer(DocumentingTemplateRenderer): @@ -385,7 +385,7 @@ class DocumentingXHTMLRenderer(DocumentingTemplateRenderer): media_type = 'application/xhtml+xml' format = 'xhtml' - template = 'renderer.html' + template = 'djangorestframework/api.html' class DocumentingPlainTextRenderer(DocumentingTemplateRenderer): @@ -397,7 +397,7 @@ class DocumentingPlainTextRenderer(DocumentingTemplateRenderer): media_type = 'text/plain' format = 'txt' - template = 'renderer.txt' + template = 'djangorestframework/api.txt' DEFAULT_RENDERERS = ( diff --git a/djangorestframework/templates/djangorestframework/api.html b/djangorestframework/templates/djangorestframework/api.html new file mode 100644 index 000000000..fd9bcc983 --- /dev/null +++ b/djangorestframework/templates/djangorestframework/api.html @@ -0,0 +1,3 @@ +{% extends "djangorestframework/base.html" %} + +{# Override this template in your own templates directory to customize #} \ No newline at end of file diff --git a/djangorestframework/templates/renderer.txt b/djangorestframework/templates/djangorestframework/api.txt similarity index 100% rename from djangorestframework/templates/renderer.txt rename to djangorestframework/templates/djangorestframework/api.txt diff --git a/djangorestframework/templates/renderer.html b/djangorestframework/templates/djangorestframework/base.html similarity index 85% rename from djangorestframework/templates/renderer.html rename to djangorestframework/templates/djangorestframework/base.html index bda49e6f8..1d4ae92ae 100644 --- a/djangorestframework/templates/renderer.html +++ b/djangorestframework/templates/djangorestframework/base.html @@ -7,26 +7,34 @@ - Django REST framework - {{ name }} + {% block extrastyle %}{% endblock %} + {% block title %}Django REST framework - {{ name }}{% endblock %} + {% block extrahead %}{% endblock %} + {% block blockbots %}{% endblock %} - +
+
{% if 'OPTIONS' in view.allowed_methods %} @@ -123,7 +131,12 @@ {% endif %}
+ +
+ + + {% block footer %}{% endblock %} diff --git a/djangorestframework/templates/api_login.html b/djangorestframework/templates/djangorestframework/login.html similarity index 100% rename from djangorestframework/templates/api_login.html rename to djangorestframework/templates/djangorestframework/login.html diff --git a/djangorestframework/utils/staticviews.py b/djangorestframework/utils/staticviews.py index 9bae0ee78..7cbc0b9b8 100644 --- a/djangorestframework/utils/staticviews.py +++ b/djangorestframework/utils/staticviews.py @@ -12,7 +12,7 @@ import base64 # be making settings changes in order to accomodate django-rest-framework @csrf_protect @never_cache -def api_login(request, template_name='api_login.html', +def api_login(request, template_name='djangorestframework/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm): """Displays the login form and handles the login action.""" @@ -57,5 +57,5 @@ def api_login(request, template_name='api_login.html', }, context_instance=RequestContext(request)) -def api_logout(request, next_page=None, template_name='api_login.html', redirect_field_name=REDIRECT_FIELD_NAME): +def api_logout(request, next_page=None, template_name='djangorestframework/login.html', redirect_field_name=REDIRECT_FIELD_NAME): return logout(request, next_page, template_name, redirect_field_name) diff --git a/docs/howto/setup.rst b/docs/howto/setup.rst index 22f98f0c6..64b58262c 100644 --- a/docs/howto/setup.rst +++ b/docs/howto/setup.rst @@ -29,6 +29,19 @@ but once you move onto a production server, you'll want to make sure you serve t * Ensure that the ``ADMIN_MEDIA_PREFIX`` is set appropriately and that you are serving the admin media. (Django's testserver will automatically serve the admin media for you) +You may customize the templates by creating a new template called ``djangorestframework/api.html`` +in your project, extend ``djangorestframework/base.html`` and override the +appropriate ``{% block tags %}``. For example:: + + {% extends "djangorestframework/base.html" %} + + {% block title %}My API{% endblock %} + + {% block branding %} +

My API

+ {% endblock %} + + Markdown --------