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 jquery.dj.hilbert.js.
This is based on answers from the Stackoverflow question “How to manage a redirect request after a JQuery Ajax call?”.
@ajax_login_required def authenticated_view(request): return HttpResponse()
@ajax_only 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.
@anonymous_required(url='/hilbert/test/simple/') def anonymous_only_view(request): return HttpResponse()