ここの初心者。Django を使用してブログを作成しようとしています。投稿にスラッグを追加する前は、すべてが正常に機能/投稿されていました。ただし、スラッグを追加したため、DatabaseError at /admin/blogengine/post/add/ no such column: blogengine_post.slug という投稿を追加しようとすると、エラー メッセージが表示されます。エラーのトレースバックは次のとおりです。
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin
Django Version: 1.5.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'blogengine',
'django.contrib.admin')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Template error:
In template /Users/chrissiepollock/projects/DjangoBlog/templates/posts.html, error at line 6
no such column: blogengine_post.slug
1 : <html>
2 : <head>
3 : <title>My Django Blog</title>
4 : </head>
5 : <body>
6 : {% for post in posts %}
7 : <h1><a href="/{{ post.slug }}">{{ post.title }}</a></h1>
8 : <h3>{{ post.pub_date }}</h3>
9 : {{ post.text }}
10 : {% endfor %}
11 : <br />
12 : {% if page.has_previous %}
13 : <a href="/{{ page.previous_page_number }}/">Previous Page</a>
14 : {% endif %}
15 : {% if page.has_next %}
16 : <a href="/{{ page.next_page_number }}/">Next Page</a>
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/chrissiepollock/projects/DjangoBlog/blogengine/views.py" in getPost
27. return render_to_response('posts.html', { 'posts':post})
File "/Library/Python/2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
29. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/Library/Python/2.7/site-packages/django/template/loader.py" in render_to_string
172. return t.render(Context(dictionary))
File "/Library/Python/2.7/site-packages/django/template/base.py" in render
140. return self._render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/Library/Python/2.7/site-packages/django/template/base.py" in render
830. bit = self.render_node(node, context)
File "/Library/Python/2.7/site-packages/django/template/debug.py" in render_node
74. return node.render(context)
File "/Library/Python/2.7/site-packages/django/template/defaulttags.py" in render
148. len_values = len(values)
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in __len__
90. self._result_cache = list(self.iterator())
File "/Library/Python/2.7/site-packages/django/db/models/query.py" in iterator
301. for row in compiler.results_iter():
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
775. for rows in self.execute_sql(MULTI):
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
840. cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/util.py" in execute
41. return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
366. six.reraise(utils.DatabaseError, utils.DatabaseError(*tuple(e.args)), sys.exc_info()[2])
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
362. return Database.Cursor.execute(self, query, params)
Exception Type: DatabaseError at /admin
Exception Value: no such column: blogengine_post.slug
私はmanage.py sqlall myappを実行しました。それによると、スラッグ情報はそこにあります(何か間違ったことを読んでいない限り):
CREATE TABLE "blogengine_post" (
"id" integer NOT NULL PRIMARY KEY,
"title" varchar(200) NOT NULL,
"pub_date" datetime NOT NULL,
"text" text NOT NULL,
"slug" varchar(40) NOT NULL UNIQUE
) ;
私は何日もこれを理解しようとしてきました.行ごとの読み通しを行い、ゼロから始めてファイルとフォルダーを再配置しましたが、何も機能しません. 何か案は?よろしくお願いいたします。