Below is the list of decorators available in this project.


This decorator works like the built-in Django login_required but it handles AJAX requests differently. For AJAX requests, this decorator passes back custom headers to tell the client to redirect to the login page. These headers are caught by a ajaxComplete listener contained within

This is based on answers from the Stackoverflow question “How to manage a redirect request after a JQuery Ajax call?”.

def authenticated_view(request):
    return HttpResponse()


The ajax_only decorator ensures that all requests made to a particular view are made as AJAX requests. Non-AJAX requests will recieve a 400 (Bad Request) response. This is based on snippet 771.

def ajax_view(request):
    return HttpResponse()


New in version 0.2.

This decorator is the opposite of login_required . It ensures that users attempting to view this page are not authenticated. By default this will redirect autheticated users to the server root ‘/’ or you can specify another url as either an absolute path or as as named url pattern.

def anonymous_only_view(request):
    return HttpResponse()


New in version 0.2.

This decorator is similar to SSLRedirectMiddleware but works independently. Decorating a view with secure will force this view to be accessed only over SSL.

def secure_view(request):
    return HttpResponse()

Project Versions

Table Of Contents

Previous topic


Next topic


This Page