Create a Simple Login URL with Django

Django
2015-05-29 11:31 (10 years ago)
Create a Simple Login URL with Django
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
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Categories

Archive