S
S
sazhyk2016-09-28 13:16:40
Django
sazhyk, 2016-09-28 13:16:40

How to organize work on the site only after authorization?

I already asked this question. There he is. I don't know how to draw more attention to him, but I need help.
I thought that this is already implemented in the dzhangi admin panel. But I don’t know how to implement the same at home, or how to use their code in my project. Just not enough knowledge. Please help with some advice. Maybe someone has already implemented something similar? Share your experience.
Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2016-09-28
@sazhyk

For example, if you use common based views:

from django.contrib.auth.decorators import login_required
class LoginRequiredMixin(object):

    @classmethod
    def as_view(cls, **initkwargs):
        view = super(LoginRequiredMixin, cls).as_view(**initkwargs)
        return login_required(view, login_url=reverse_lazy('login'))

hang this mixin on all views, and when they try to log in under an unauthorized user, they will redirect him to the login page for authorization.
In general, a bunch of possible options have already been advised to you in that topic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question