我一直在关注django注册的在线教程。他们正在使用django-registration-redux==1.1
,我必须使用django-registration-redux==1.4
。我启动本地服务器并转到:http://127.0.0.1:8000/accounts/register/
然后我看到了这个错误:
TemplateDoesNotExist at /accounts/register/
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/register/
Django Version: 1.9
Python Version: 2.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
'store']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template loader postmortem
Django tried loading these templates, in this order:
Using engine django:
* django.template.loaders.app_directories.Loader: /Library/Python/2.7/site-packages/django/contrib/admin/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /Library/Python/2.7/site-packages/django/contrib/auth/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /Library/Python/2.7/site-packages/registration/templates/base.html (Source does not exist)
* django.template.loaders.app_directories.Loader: /Users/xx/Desktop/stoneriverelearning/bookstore/store/templates/base.html (Source does not exist)
Template error:
In template /Library/Python/2.7/site-packages/registration/templates/registration/registration_form.html, error at line 1
base.html 1 : {% extends "registration/ registration_base.html" %}
2 : {% load i18n %}
3 :
4 : {% block title %}{% trans "Register for an account" %}{% endblock %}
5 :
6 : {% block content %}
7 : <form method="post" action="">
8 : {% csrf_token %}
9 : {{ form.as_p }}
10 : <input type="submit" value="{% trans 'Submit' %}" />
11 : </form>
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
174. response = self.process_exception_by_middleware(e, request)
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
172. response = response.render()
File "/Library/Python/2.7/site-packages/django/template/response.py" in render
160. self.content = self.rendered_content
File "/Library/Python/2.7/site-packages/django/template/response.py" in rendered_content
137. content = template.render(context, self._request)
File "/Library/Python/2.7/site-packages/django/template/backends/django.py" in render
97. reraise(exc, self.backend)
File "/Library/Python/2.7/site-packages/django/template/backends/django.py" in reraise
107. six.reraise(exc.__class__, new, sys.exc_info()[2])
File "/Library/Python/2.7/site-packages/django/template/backends/django.py" in render
95. return self.template.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in render
206. return self._render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in _render
197. return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in render
988. bit = node.render_annotated(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in render_annotated
955. return self.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in render
173. return compiled_parent._render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in _render
197. return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in render
988. bit = node.render_annotated(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in render_annotated
955. return self.render(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in render
151. compiled_parent = self.get_parent(context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in get_parent
148. return self.find_template(parent, context)
File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in find_template
128. template_name, skip=history,
File "/Library/Python/2.7/site-packages/django/template/engine.py" in find_template
169. raise TemplateDoesNotExist(name, tried=tried)
Exception Type: TemplateDoesNotExist at /accounts/register/
Exception Value: base.html
我得到的不同之处在于我必须在这个较新的版本中做一些不同的事情,以便找到所有新的注册html文件和txt文件(用于电子邮件),但我该怎么办?< / p>
编辑:
所以,谢谢你指出这里的空间:
{% extends "registration/ registration_base.html" %}
如何删除?我在我的代码中没有这个。
这是我的网址文件:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^store/', include('store.urls'), name='store'),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^admin/', include(admin.site.urls)),
谢谢:)
答案 0 :(得分:0)
在引用文件名时,模板的第1行看起来有空格。如果不是这样,你可能有另一个本地命名注册的文件夹,django正在寻找而不是注册包。