学习“利用django学习网站开发”。 在第3章,在建立图书标识数据模型时,我遵循了除“外”以外的指示和代码。
from django.contrib.auth.models import User
class Bookmark(models.Model):
title = models.CharField(maxlength=200)
user = models.ForeignKey(User)
link = models.ForeignKey(Link)
一、导 言
title = models.CharField(maxlength=200)
页: 1
title = models.CharField(max_length=200)
我正在收到错误信息。 之后,我管理着 p。 py syncdb, 然后,python管理。 py sql bookmarks. 当我检查。 我收到这一错误信息:
Request Method: GET
Request URL: http://127.0.0.1:8000/user/j/
Django Version: 1.3
Exception Type: TemplateSyntaxError
Exception Value:
**Caught DatabaseError while rendering: no such column: bookmarks_bookmark.title**
Looking this up, I learned that sqlite3, the database i was using, cannot find bookmarks_bookmark.title. I went back 页: 1the book to make sure I have everything copied correctly, and I did except for that part that I changed (max_length). When I ran python manage.py sql bookmarks, it gave me--
BEGIN;
CREATE TABLE "bookmarks_bookmark" (
"id" integer NOT NULL PRIMARY KEY,
"title" varchar(200) NOT NULL,
"user_id" integer NOT NULL REFERENCES
"auth_user" ("id"),
"link_id" integer NOT NULL REFERENCES
"bookmarks_link" ("id"),
);
CREATE TABLE "bookmarks_link" (
"id" integer NOT NULL PRIMARY KEY,
"url" varchar(200) NOT NULL UNIQUE
);
COMMIT;
我如何确定这一点? 感谢!