How to access login_required url?

  • 0
    Yes means url:
    url(r'^links$', login_required(views.LinkListView.as_view()), name='links')

    and view:
    class LinkListView(ListView):
        model = Link
        template_name = "app/links.html"

    in html:
    href = "{% url 'links'%}"
    I get an error
    I have already googled that it is so easy not to contact the login_required url, but I could not find a clear answer.
    Django Anonymous, Aug 30, 2020

  • 1 Answers
  • 0
    url(r'^links$', login_required(views.LinkListView.as_view(), login_url=reverse_lazy('your_login_url')), name='links')

    In general, it is more beautiful to put it into a mixin.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!