开发者

Django not create database table

Hey, I've a database already created. Now I've updated UserProfile with:

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique = True, related_name =开发者_开发百科 'user')
    follows = models.ManyToManyField("self", related_name = 'follows') <-- NEW LINE

so python manage.py sqlall myapp returns me:

[...]
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")
)
[...]

When I run python manage.py syncdb:

Creating tables ...
Installing custom SQL ...
Installing indexes ...
No fixtures found.

But the table is not created when I try to insert data into. Why? (I'm testing locally, with sqlite3)


manage.py syncdb will not modify existing tables to add or remove fields. You will need to either manually modify your database, or use a tool like South to create automated database migrations (which is what I highly recommend)


have you added your app to INSTALLED_APPS in settings.pys:

settings.py

INSTALLED_APPS = (
    ... ,
    'my_app',
)

https://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#installed-apps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜