문제

Using django, I need to add a new field such as ManyToManyField to a existing model. How can I update my database using South? I have tried

python manage.py schemamigration appname --initial

and

python manage.py migrate appname --fake

but still getting error message 'no such table'.

I have some data in my database which will take some time to import so I don't want to clear my database. I'm not familiar with SQL language, so is there any convenient way to solve this?

도움이 되었습니까?

해결책

The database currently reflects your models without the new field so you need to create your initial migrations first without the new field in the model. Once you have done that and created your initial 0001 migration you can add the new field, run

python manage.py schemamigration --auto appname

which will create the SQL necessary to create the news field, and then

pytho manage.py migrate

to actually run the migration

다른 팁

--fake mean no changes will be made to db. You should

  1. remove new field,
  2. make initial migration without it,
  3. then add new field, do schemamigration with it
  4. and then migrate.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top