By default, all of the settings are optional and define sane and secure defaults.

The url or view name for the sudo view. Default: sudo.views.sudo
Default url to be redirected to after elevating permissions. Default: /
The querystring argument to be used for redirection. Default: next
How long should sudo mode be active for? Duration in seconds. Default: 10800
The domain to bind the sudo cookie to. Default: current exact domain.

Should the cookie only be accessible via http requests? Default: True


If this is set to False, any JavaScript files have the ability to access this cookie, so this should only be changed if you have a good reason to do so.

The name of the cookie to be used for sudo mode. Default: sudo
Restrict the sudo cookie to a specific path. Default: /

Only transmit the sudo cookie over https if True. Default: matches current protocol


By default, we will match the protocol that made the request. So if your sudo page is over https, we will set the secure flag on the cookie so it won’t be transmitted over plain http. It is highly recommended that you only use django-sudo over https.

An extra salt to be added into the cookie signature. Default: ‘’
The name of the session attribute used to preserve the redirect destination between the original page request and successful sudo login. Default: sudo_redirect_to

Set up URLs

We need to hook up one url to use django-sudo properly. At minimum, you need something like the following:

(r'^sudo/$',  # Whatever path you want
    'sudo.views.sudo',  # Required
    {'template_name': 'sudo/sudo.html'}  # Optionally change the template to be used

Required Template

To get up and running, we last need to create a template for the sudo page to render. By default, the package will look for sudo/sudo.html but can easily be overwritten by setting the template_name when defining the url definition as seen above.


This template gets rendered with the the following context:

An instance of SudoForm.
The value of ?next=/foo/. If SUDO_REDIRECT_FIELD_NAME is name, then expect to find {{ next }} in the context, with the value of /foo/.

After configuring things, we can now start securing pages.