mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-31 18:40:07 +03:00
Update documentation on HTMLFormRenderer
Add verbose message about renderer not found
This commit is contained in:
parent
90ed2c1ef7
commit
1d48aaa8b9
|
@ -92,7 +92,7 @@ The following view demonstrates an example of using a serializer in a template f
|
|||
|
||||
The `render_form` tag takes an optional `template_pack` argument, that specifies which template directory should be used for rendering the form and form fields.
|
||||
|
||||
REST framework includes three built-in template packs, all based on Bootstrap 3. The built-in styles are `horizontal`, `vertical`, and `inline`. The default style is `horizontal`. To use any of these template packs you'll want to also include the Bootstrap 3 CSS.
|
||||
REST framework includes three built-in template packs, all based on Bootstrap 3. The built-in styles are `horizontal`, `vertical`, and `inline`. The default style is `vertical`. To use any of these template packs you'll want to also include the Bootstrap 3 CSS.
|
||||
|
||||
The following HTML will link to a CDN hosted version of the Bootstrap 3 CSS:
|
||||
|
||||
|
@ -144,13 +144,15 @@ Presents labels and controls alongside each other, using a 2/10 column split.
|
|||
|
||||
*This is the form style used in the browsable API and admin renderers.*
|
||||
|
||||
Note: make sure you add "form-horizontal" class to `form` tag as per Bootstrap 3 guidelines.
|
||||
|
||||
{% load rest_framework %}
|
||||
|
||||
...
|
||||
|
||||
<form class="form-horizontal" action="{% url 'login' %}" method="post" novalidate>
|
||||
{% csrf_token %}
|
||||
{% render_form serializer %}
|
||||
{% render_form serializer template_pack='rest_framework/horizontal' %}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-default">Sign in</button>
|
||||
|
|
|
@ -85,7 +85,9 @@ class DefaultContentNegotiation(BaseContentNegotiation):
|
|||
renderers = [renderer for renderer in renderers
|
||||
if renderer.format == format]
|
||||
if not renderers:
|
||||
raise Http404
|
||||
raise Http404('Renderer for (%s) not found. Did you enable it with'
|
||||
' DEFAULT_RENDERER_CLASSES or within the APIView'
|
||||
' / ViewSet?' % format)
|
||||
return renderers
|
||||
|
||||
def get_accept_list(self, request):
|
||||
|
|
|
@ -81,7 +81,7 @@ def exception_handler(exc, context):
|
|||
to be raised.
|
||||
"""
|
||||
if isinstance(exc, Http404):
|
||||
exc = exceptions.NotFound()
|
||||
exc = exceptions.NotFound(*exc.args)
|
||||
elif isinstance(exc, PermissionDenied):
|
||||
exc = exceptions.PermissionDenied()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user