Pergunta

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?

Foi útil?

Solução

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

Outras dicas

--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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top