嘿, 我已經創建了一個數據庫。用現在我已經更新用戶配置:Django不創建數據庫表
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True, related_name = 'user')
follows = models.ManyToManyField("self", related_name = 'follows') <-- NEW LINE
所以python manage.py sqlall myapp
返回我:
[...]
CREATE TABLE "myapp_userprofile_follows" (
"id" integer NOT NULL PRIMARY KEY,
"from_userprofile_id" integer NOT NULL,
"to_userprofile_id" integer NOT NULL,
UNIQUE ("from_userprofile_id", "to_userprofile_id")
)
[...]
當我運行python manage.py syncdb
:
Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.
但是,當我嘗試插入不創建表數據進入。爲什麼? (我在本地測試,使用sqlite3)
見http://stackoverflow.com/a/27204663/847501 – Rafiq 2014-11-29 17:31:01