开发者

SQL commands generated in Django by running sqlall

开发者 https://www.devze.com 2023-01-03 22:04 出处:网络
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:

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

0

精彩评论

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