Django: How can I apply the login_required decorator to my entire site (excluding static media)?

前端 未结 10 2004
日久生厌
日久生厌 2020-12-24 07:21

The example provides a snippet for an application level view, but what if I have lots of different (and some non-application) entries in my \"urls.py\" file, including templ

10条回答
  •  伪装坚强ぢ
    2020-12-24 08:09

    In addition to meder omuraliev answer if you want exempt url like this (with regexp):

    url(r'^my/url/(?P[0-9]+)/$', views.my_view, name='my_url')
    

    add it to EXEMPT_URLS list like this:

    LOGIN_EXEMPT_URLS = [r'^my/url/([0-9]+)/$']
    

    r'..' in the beginning of the string necessary.

提交回复
热议问题