Не запускается блог на Django - Python
Формулировка задачи:
http://blog.myfreeweb.ru/post/howto_write_django_blog_engine/
вот по этому тутору пробую написать свой первый блог.
на выходе получаю ошибку
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'O:\mysite2\mysite2\database.db', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
TIME_ZONE = 'Europe/Moscow'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_ROOT = 'O:/mysite2/mysite2/media/'
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
SECRET_KEY = '%1_dn%(7t#mmlfwk-&pa91y%_8x^^hj@nt%v+2kb^d-m3vbjmx'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'mysite2.urls'
WSGI_APPLICATION = 'mysite2.wsgi.application'
TEMPLATE_DIRS = (
'O:/mysite2/mysite2/templates/'
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'mysite2.blog',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}from django.db import models
class Category(models.Model):
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name
class Post(models.Model):
category = models.ForeignKey(Category)
name = models.CharField(max_length=100)
datetime = models.DateTimeField('Date published')
content = models.TextField(max_length=100000)
def __unicode__(self):
return self.namefrom mysite2.blog.models import Category, Post
from django.contrib import admin
admin.site.register([Category, Post])from django.shortcuts import render_to_response
from mysite2.blog.models import Category, Post
def main(request):
posts = Post.objects.order_by('-id')
categories = Category.objects.order_by('-id')
return render_to_response('index.html', {'posts': posts, 'categories': categories, 'iscomments': 'false'})
def category(request, category_id):
posts = Post.objects.filter(category=category_id).order_by('-id')
categories = Category.objects.order_by('-id')
return render_to_response('index.html', {'posts': posts, 'categories': categories, 'iscomments': 'false'})
def post(request, post_id):
posts = Post.objects.filter(id=post_id)
categories = Category.objects.order_by('-id')
return render_to_response('index.html', {'posts': posts, 'categories': categories, 'iscomments': 'true'})from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
)
urlpatterns += patterns('mysite2.blog.views',
(r'^$', 'main'),
(r'^category/(?P<category_id>\d+)/$', 'category'),
(r'^post/(?P<post_id>\d+)/$', 'post'),
(r'^admin/(.*)', admin.site.urls),
(r'^comments/', include('django.contrib.comments.urls')),
)<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
<title>Блог Василия Пупкина</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
#header {
background: #edd400;
margin-bottom: 1em;
}
h1 { font: 2em sans-serif; }
h2 { font: 1.2em sans-serif; }
#sidebar {
background: #c4a000;
float: left;
width: 10em;
display: inline;
margin-left: 1em;
}
#content {
margin-left: 12em;
margin-right: 1em;
}
.post {
background: #c4a000;
padding: 1em;
margin: 1em 0em 1em 0em;
}
.meta {
border: 0.2em dotted #edd400;
margin: 0.1em;
}
#footer {
background: #edd400;
clear: both;
}
</style>
</head>
<body>
<div id="header">
<h1><a href="/">Блог Василия Пупкина</a></h1>
<h2>Работает на Django</h2>
</div>
<div id="sidebar">
Категории:
<ul>
{% for category in categories %}
<li><a href="/category/{{ category.id }}">{{ category.name }}</a></li>
{% endfor %}
</ul>
</div>
<div id="content">
{% for post in posts %}
<div class="post">
<div class="meta">{{ post.datetime }} <a href="/category/{{ post.category.id
}}">{{ post.category.name }}</a> > <a href="/post/{{ post.id }}">{{ post.name }}</a></div>
{{ post.content }}
{% ifequal iscomments 'true' %}
{% load comments %}
{% get_comment_list for post as allcomments %}
{% for acomment in allcomments %}
<div class="meta"><a href="{{ acomment.user_url }}">{{ acomment.user_name }}
</a>: {{ acomment.comment }}</div>
{% endfor %}
<div class="meta">{% render_comment_form for post %}</div>
{% endifequal %}
</div>
{% endfor %}
</div>
<div id="footer">
<p>Разметка от <a href="http://myfreeweb.ru">MyFreeWeb.ru</a></p>
</div>
</body>
</html>
NoReverseMatch at /admin/
Reverse for 'logout' with arguments '()' and keyword arguments '{}' not found.Request Method: GET
Request URL: [url]http://127.0.0.1:8000/admin/[/url]
Django Version: 1.4
Exception Type: NoReverseMatch
Exception Value: Reverse for 'logout' with arguments '()' and keyword arguments '{}' not found.
Exception Location: C:\Python27\lib\site-packages\django\core\urlresolvers.py in _reverse_with_prefix, line 396
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2
Python Path: ['o:\\mysite2',
'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
'C:\\Python27\\lib\\site-packages\\PIL']
Server time: Thu, 7 Jun 2012 10:40:13 +0300Решение задачи: «Не запускается блог на Django»
textual
Листинг программы
(r'^admin/', include('admin.site.urls')),