Django TemplateDoesNotExist admin/login.html

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 07:24:05

You can try to add the admin tempates path name to TEMPLATES['DIRS'] in your django settings.py

The default TEMPLATES:

'DIRS': [os.path.join(BASE_DIR, 'templates')]

change to if you are using Django project created by Pycharm:

'DIRS': [os.path.join(BASE_DIR, 'templates'),
         os.path.join(BASE_DIR, 'venv/lib/site-packages/django/contrib/admin/templates')]

Assuming that you are trying to use the default Django admin, be sure that 'django.contrib.admin' is in the INSTALLED_APPS section of your settings.py file.

I got that same error trying to use the default built-in login functionality.

My settings.py has the default settings, 'django.contrib.admin' is in the INSTALLED_APPS section of my settings.py file, as suggested by sean.

Elaborating on Tim's answer, I believe that we are refering to a missing template.

See the docs at https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.views.login: "It’s your responsibility to provide the html for the login template, called registration/login.html by default."

If you're getting a "TemplateDoesNotExist" error, that means you are referring to a template that does not exist. :) You should have a templates directory, and check to see if admin/login.html exists in that directory path.

This is the Django 1.4 template documentation. IMO the Django documentation is quite good compared to most stock documentation.

Also you should know that the admin interface is not really designed to be customized. The built-in admin interface has a login feature already built-in, if you create a superuser with the manage.py script. If you're trying to build your own template, you should do so separate from the admin interface, unless you disable/remove the built-in admin interface completely and design your own from scratch. Modifying built-in admin code is more trouble than it's worth in my opinion.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!