Run the given method prior to the decorated view.

If you return anything besides None from the given method, its return values will replace the arguments of the decorated view.

If you return an instance of HttpResponse from the given method, Respite will return it immediately without delegating the request to the decorated view.

Example usage:

class ArticleViews(Views):

    def show(self, request, article):
        return self._render(
            request = request,
            template = 'show',
            context = {
                'article': article

    def _load(self, request, id):
            return request, Article.objects.get(id=id)
        except Article.DoesNotExist:
            return self._error(request, 404, message='The article could not be found.')
Parameters:method – A string describing a class method.

Override the views class’ supported formats for the decorated function.

Arguments: formats – A list of strings describing formats, e.g. ['html', 'json'].

Previous topic


Next topic


This Page