How to programmatically generate the CREATE TABLE SQL statement for a given model in Django?
- 阅读更多 关于 How to programmatically generate the CREATE TABLE SQL statement for a given model in Django?
问题 I need to programmatically generate the CREATE TABLE statement for a given unmanaged model in my Django app ( managed = False ) Since i'm working on a legacy database, i don't want to create a migration and use sqlmigrate . The ./manage.py sql command was useful for this purpose but it has been removed in Django 1.8 Do you know about any alternatives? 回答1: As suggested, I post a complete answer for the case, that the question might imply. Suppose you have an external DB table, that you