Sometimes you might want to provide a response in some format even if thethose in the Accept header can't be honoured. This is useful when providingerror responses in a different format to the client's expected format. To dothis, set the ``_force_fallback_format`` attribute to the name of the format::

class MyView(ContentNegotiatedView): _force_fallback_format = 'html'

If a client doesn't provide an Accept header, then you can specify a defaultformat with ``_default_format``::

class MyView(ContentNegotiatedView): _default_format = 'html'

Built-in renderer views~~~~~~~~~~~~~~~~~~~~~~~

``django_conneg`` includes the following built-in renderers in the``django_conneg.views`` module:

* ``HTMLView`` (renders a ``.html`` template with media type ``text/html``)* ``TextView`` (renders a ``.txt`` template with media type ``text/plain``)* ``JSONView`` (coerces the context to JavaScript primitives and returns as ``application/json``)* ``JSONPView`` (as ``JSONView``, but wraps in a callback and returns as ``application/javascript``)

Using these, you could define a view that renders to both HTML and JSON like this::

As higher-numbered priorities are preferred, this will result in HTML alwaysbeing prefered over XML in ambiguous situations.

By default, ``django-conneg``'s built-in renderers have a priority of 0, exceptfor ``HTMLView`` and ``TextView``, which each have a priority of 1 for thereason given above.

Improved 40x response handling------------------------------

Django provides a couple of useful exceptions, ``Http404`` and``PermissionDenied``, which you may want to use in your application. However,it's only possible to customise the 404 site-wide (either by providing a``404.html`` template, or by setting ``handler404`` in your urlconf), anduntil Django 1.4 comes out, PermissionDenied will always result in a veryspartan error page.

``django-conneg`` provides an ``ErrorCatchingView`` which you can use as amixin to customise the rendering of responses for these error situations::