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 syncdbwill 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)