Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>"snippets" does not point to a specific element of Django, it just means : here is a piece of code for you to use. In this case, it's a Middleware, a specific Django module that will be called before and after a web request. <a href="http://docs.djangoproject.com/en/dev/topics/http/middleware/" rel="nofollow">Read django docs</a> if needed </p> <p>I use this middleware too, just paste everything in a file called <code>middleware.py</code> in your main application folder (any app folder will do, given this app is mentioned in <code>INSTALLED_APPS</code>)</p> <p>Then add these lines in your <code>settings.py</code> file : </p> <pre><code>MIDDLEWARE_CLASSES = ( #...all others middleware, on the last line, paste : 'main.middleware.EnforceLoginMiddleware', ) </code></pre> <p>Note that here the app where I put the file is called <code>main</code>, yours may be named differently.</p> <p>Don't forget to read the docstring of the snippet :</p> <pre><code>Middlware class which requires the user to be authenticated for all urls except those defined in PUBLIC_URLS in settings.py. PUBLIC_URLS should be a tuple of regular expresssions for the urls you want anonymous users to have access to. If PUBLIC_URLS is not defined, it falls back to LOGIN_URL or failing that '/accounts/login/'. Requests for urls not matching PUBLIC_URLS get redirected to LOGIN_URL with next set to original path of the unauthenticted request. Any urls statically served by django are excluded from this check. To enforce the same validation on these set SERVE_STATIC_TO_PUBLIC to False. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload