[Django]-Django convert Model to sql code


If you’re looking for the specific pieces of code, have a look at django.db.backends.base.creation to see how the sql is generated, of course there need to be individual implementations for different database types, so for example also see django.db.backends.postgresql_psycopg2.creation!




I am not exactly sure what you mean, but you can get the SQL for all the tables in an app by running this command:
python manage.py sqlall your_app

👤Ivan P

Leave a comment