Create a Simple Login URL with Django

Django
2015-05-29 20:31 (9 years ago) ytyng
url(r'^login/', 'django.contrib.auth.views.login', name='login',
    kwargs={'template_name': 'admin/login.html',
            'extra_context': {'next': '/'}}),

Write this link in the template as follows,

<a href="{% login %}">Login</a>

and when clicked, the login page will appear. After completing the login, you will be redirected to /.

At the time of evaluation, if the URL of the top page is registered, I think it is possible to put the reversed URL in the next argument, but it seems difficult timing-wise, so we directly specify /.

Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011