1

I am working Django 1.8 and having trouble using my custom login page. Whenever I go to my login url, the Django admin username and password form comes up instead of my custom login.html.

I have worked in the Django 1.7 and this works fine but I do not know why I am having the error in 1.8.

login.html is my custom login template.

My urls:

 url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'admin/login.html'}, name='auth_login'),

I have checked the forums and the Google but still cannot find a similar error.

EDIT:

Answer thanks to Kishor.

In Django 1.8 I simply renamed the admin pages that I was using, namely, base.html, base_site.html and login.html [I store these files inside a folder called 'admin' which is inside my app's 'templates' folder]

Instead of using the normal way like in previous versions of Django i just called the three pages above myapp_base.html, myapp_base_site.html and myapp_login.html [Do not forget to also change the tag at the top inside these pages where is says 'extends']

From there my app was able to pick up that I wanted to override the standard Django login page and customize it to my specification.

AKaY
  • 17
  • 6
  • Can you try changing the file name? – Kishor Pawar Aug 19 '15 at 08:55
  • do you have your own folder called admin? that will likely conflict with django admin.. – Sayse Aug 19 '15 at 08:59
  • I changed the name of the file to newname_login.html instead of login.html and that seems to have made some difference. I took the login page from my old 1.7 project so obviously the images wont show due to different names. Now i have the django administration bar at the top but i cannot get rid of it. i saw the issue here but i think I am still doing something wrong: http://stackoverflow.com/questions/4938491/django-admin-change-header-django-administration-text. Its only been a few minutes that i have been stuck on this so I will continue trying for a bit longer before im back here – AKaY Aug 19 '15 at 09:11

1 Answers1

1

Use this 1.8 way/generic view way
url(r'^accounts/login/$', auth_views.login, {'template_name': 'myapp/login.html'}),

and be sure that you have included
url('^', include('django.contrib.auth.urls'))

Kishor Pawar
  • 3,386
  • 3
  • 28
  • 61
  • I changed the name and that worked. Just working on removing the django administration header at the top now. Thanks for the Help. – AKaY Aug 19 '15 at 09:15
  • Have you copied the `registration/login.html.` or created new on your own? – Kishor Pawar Aug 19 '15 at 09:48
  • I created my own. i always add an admin folder for the templates that include the login.html page and then i add myapp folder seperately and that worked fine in previous versions. Just a few new things i am seeing in 1.8. managed to sort out the new way of loading static files as well now. – AKaY Aug 19 '15 at 10:30