Renderers

Contains template renderers.

To use, declare renderers in settings.py, like so:

REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
        'dynamicforms.renderers.TemplateHTMLRenderer',
    )
}

Class reference

class HTMLFormRenderer[source]

An HTML renderer for use with templates.

The data supplied to the Response object should be a dictionary that will be used as context for the template.

The template name is determined by (in order of preference):

  1. An explicit .template_name attribute set on the response.
  2. An explicit .template_name attribute set on this class.
  3. The return result of calling view.get_template_names().
For example:
data = {‘users’: User.objects.all()} return Response(data, template_name=’users.html’)
render(data, accepted_media_type=None, renderer_context=None)[source]

Render serializer data and return an HTML form, as a string.

class TemplateHTMLRenderer[source]

Renderers serializer data into an HTML form.

If the serializer was instantiated without an object then this will return an HTML form not bound to any object, otherwise it will return an HTML form with the appropriate initial data populated from the object.

Note that rendering of field and form errors is not currently supported.

render(data, accepted_media_type=None, renderer_context=None)[source]

Renders data to HTML, using Django’s standard template rendering.

The template name is determined by (in order of preference):

  1. An explicit .template_name set on the response.
  2. An explicit .template_name set on this class.
  3. The return result of calling view.get_template_names().