Форум сайта python.su
я в замешательстве :( , когда дело дошло до подключения авторизации я напоролся на TemplateDoesNotExist
после такого я попробовал как в книжке, то есть url, views, templates, но ничего не поменялось:
TemplateDoesNotExist at /accounts/login/
registration/login.html
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
Офлайн
Думаю по этому куску кода мало, что понятно. Какой сервер вы используете встроенный в Django или другой. Прикрепите код views и url а там что надумаем.
Офлайн
использую встроенный сервер
urls:
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from inform.views import login
from django.contrib.auth.views import login, logout
urlpatterns = patterns('',
(r'^accounts/$', login),
(r'^accounts/logout/$', logout),
)
from django.http import HttpResponseRedirect
from django.contrib import auth
def login(request):
username = request.POST['username']
password = request.POST['password']
user = auth.authenticate(username=username, password=password)
if user is not None and user.is_active:
auth.login(request, user)
return HttpResponseRedirect("/")
else:
return HttpResponseRedirect("/")
def logout(request):
auth.logout(request)
return HttpResponseRedirect("/")
<html>
<head><title>Тест</title></head>
<body>
<form method="post" action="" class="fullForm">{% csrf_token %}
<table>
<thead><h1>Авторизация:</h1></thead>
<tr>
<th>E-mail:</th>
<td>{{form.username}}</td>
</tr>
<tr>
<th>{{form.password.label}}:</th>
<td>{{form.password}}</td>
</tr>
<tr><th></th><td class="button"><button class="btn" type="submit"><span><span>Вход</span></span
</table>
</form>
</body>
</html>
Офлайн
все это дает :
TemplateDoesNotExist at /accounts/
registration/login.html
Request Method: GET
Request URL: http://localhost:8000/accounts/
Django Version: 1.2.3
Exception Type: TemplateDoesNotExist
Exception Value:
registration/login.html
Exception Location: /usr/lib/python2.6/site-packages/django/template/loader.py in find_template, line 138
Python Executable: /usr/bin/python
Python Version: 2.6.2
Python Path: ['/var/www/html/inform', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/PIL', '/usr/lib64/python2.6/site-packages/gst-0.10', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib64/python2.6/site-packages/webkit-1.0', '/usr/lib/python2.6/site-packages']
Server time: Срд, 27 Окт 2010 17:09:04 +0300
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
Офлайн
Я вижу, что template вообще не подключен как и для logina и для logout подключите template и радуйтесь.
Офлайн
GoOoviNи всетоки что вы имеете ввиду? urls? или views?
Я вижу, что template вообще не подключен как и для logina и для logout подключите template и радуйтесь.
return render_to_response('login.html', {'body':body,
})
Офлайн
простите но я окончательно запутался
ткните меня носом куда и что вставить …
Офлайн
sonniyhttp://docs.djangoproject.com/en/1.2/topics/generic-views/ вот ткну
простите но я окончательно запутался
ткните меня носом куда и что вставить …
Отредактировано (Окт. 27, 2010 18:05:57)
Офлайн
sonniyУ вас настроены пути к шаблонам в settings.py?
простите но я окончательно запутался
ткните меня носом куда и что вставить …
Офлайн
TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates'), )
(r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'myapp/login.html'}),
(r'^accounts/login/$', login, {'template_name': 'templates/login.html'}),
(r'^accounts/login/$', login, {'template_name': 'login.html'}),
Офлайн