首页 文章

疑难解答“TemplateDoesNotExist at / accounts / login /” - Django auth setup [关闭]

提问于
浏览
14

我试图在Eclipse上的新手设置上运行django-registration并运行 .

我看到django有很多帮助器视图来处理包含的 django.contrib.auth 应用程序中的登录,注销,注册等 . 我按the docs中的说明包含了 auth 网址,但登录仍然无效 . 当运行本地服务器并命中 /accounts/login/ endpoints 时,它会看到有一个 endpoints 但是 TemplateDoesNotExist 出错 .

我想弄清楚为什么内置的登录视图不起作用 . 见下面的错误:

TemplateDoesNotExist at /accounts/login/

registration/login.html

Request Method: GET
Request URL: http://localhost:8000/accounts/login/
Django Version: 1.2.4
Exception Type: TemplateDoesNotExist
Exception Value: registration/login.html

Exception Location: C:\Python25\lib\site-packages\django\template\loader.py in find_template, line 138
Python Executable: C:\Python25\python.exe
Python Version: 2.5.4
Python Path: [
  'C:\\dd\\ddproject\\src',
  'C:\\dd\\ddproject\\src',
  'C:\\Python25\\Lib\\site-packages\\django',
  'C:\\Python25\\Lib\\site-packages\\django\\contrib',
  'C:\\Python25\\Lib\\site-packages\\django\\contrib\\admin',
  'C:\\Python25\\Lib\\site-packages\\django\\db',
  'C:\\Python25\\Lib\\site-packages\\Django-1.2.4-py2.5.egg-info',
  'C:\\Python25\\Lib\\site-packages\\django\\contrib\\auth',
  'C:\\Python25\\Lib\\site-packages\\django_registration-0.7-py2.5.egg',
  'C:\\Python25\\Lib\\site-packages\\django_registration-0.7-py2.5.egg\\registration',
  'C:\\Python25',
  'C:\\Python25\\DLLs',
  'C:\\Python25\\lib',
  'C:\\Python25\\lib\\lib-tk',
  'C:\\Python25\\lib\\plat-win',
  'C:\\Python25\\lib\\site-packages',
  'C:\\Python25\\lib\\site-packages\\PIL',
  'C:\\WINDOWS\\system32\\python25.zip'
]

2 回答

  • 17

    如果您正在使用django-registration,则必须自己创建注册模板 . 默认情况下,这些应设置为/ accounts /的URL路径 .

    下面的链接有关于设置的完整说明,以及下载一些样板模板的链接 .

    http://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/

  • 3

    您是否在settings.py中定义了模板路径?

    TEMPLATE_DIRS = (
        os.path.join(os.path.dirname(__file__), 'template').replace('\\','/'),
    )
    

相关问题