How to access login_required url?
-
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
NoReverseMatch
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 -
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.Anonymous
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!