M
M
Maxim Maximov2020-02-26 14:05:06
Django
Maxim Maximov, 2020-02-26 14:05:06

Imported LoginRequiredMixin what is wrong?

I do differentiation of access rights to the site imported

from django.contrib.auth.mixins import LoginRequiredMixin
then added it to the class
class ArticleCreateView(LoginRequiredMixin, CustomSuccessMessageMixin, CreateView):
    login_url = reverse_lazy('edit_page')
    model = Articles
    template_name = 'edit_page.html'
    form_class = ArticleForm
    success_url = reverse_lazy('edit_page')
    success_msg = 'запись создана'
    def get_context_data(self,**kwargs):
        kwargs['list_articles'] = Articles.objects.all().order_by('-id')
        return super().get_context_data(**kwargs)
After that, I should be transferred to the authorization window, but in my case I get an error without a code and swears on Page not available
Site 127.0.0.1 redirected too many times.
The page may open if you delete the cookies set by this site.

Please help a newbie figure out what's what.

Terminal outputs it to infinity
52525252525252525252525252525252525252525252525252525253Fnext% 25252525252525252525252525252525252525252525252525252525252525252525253D / edit-page% 2525252525252525252525252525252525252525252525252525252525252525252525253Fnext% 2525252525252525252525252525252525252525252525252525252525252525252525253D / edit-page HTTP / 1.1 " 302 0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-02-26
@Repsol62

login_url should lead to the login page, not to the same page, that's the loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question