A
A
Astrohas2017-08-18 17:16:52
Django
Astrohas, 2017-08-18 17:16:52

How to restrict by url in django?

It is necessary to make a restriction only for authorized url addresses. Ie, for example, to restrict access to /profile/and all of its descendants only for logged in people. I don’t want to add a decorator for each view, and even worse mixins. If any way to do such restrictions?
Or do you still have to write your own middleware class?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Astrohas, 2017-08-18
@Astrohas

hmm found this hack ( https://github.com/yuexue/django_url_decr):

from django_url_decr import url_decr
from django.contrib.auth.decorators import login_required

urlpatterns = [
    url_decr(r'^profile/',
         include('profile.urls'),
         decr=login_required
    )
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question