Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing default template for login form in Django 1.5

Very simple question. When using the login_required decorator above a view, the authentication system redirects me to whatever URL is defined in LOGIN_URL in settings.py, using the template found in registration/login.html.

The question: How can I define a different template name for my login form (I don't want to use the default)?

like image 978
David Barreto Avatar asked Oct 24 '25 06:10

David Barreto


1 Answers

login documentation:

If you’d prefer not to call the template registration/login.html, you can pass the template_name parameter via the extra arguments to the view in your URLconf. For example, this URLconf line would use myapp/login.html instead:

(r'^accounts/login/$',
 'django.contrib.auth.views.login',
 {'template_name': 'myapp/login.html'}),
like image 130
Pavel Anossov Avatar answered Oct 27 '25 06:10

Pavel Anossov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!