SQL commands generated in Django by running sqlall
In my Django app, I just ran
$ python manage.py sqlall
and I see a lot of SQL statements that look like this, when describing FK r开发者_JAVA百科elationships:
ALTER TABLE `app1_model1` ADD CONSTRAINT model2_id_refs_id_728de91f FOREIGN KEY (`model2_id`) REFERENCES `app1_model2` (`id`);
Where does "7218de91f" come from? I would like to know because I'd like to manually write SQL statements to accompany models changes in the app so that my db's can be kept up to date.
Why not use a migration app to write all your SQL for you. It's definitely the smart way to go. Check out South -- part of it will be merged into Django core soon
精彩评论