[Answer]-Get SQL schema for django models


Even if you split models into multiple files, you still need to create a ‘models’ package in your app, the project structure could be,


in init.py,you need to import the model classes and set them into globals, you can do it manually or dynamically, e.g.,

from auth_* import XXXModel
current_global = globals()
current_global[XXXModel.__name__] = XXXModel

then, python manage.py sql can find the model schemas.

Leave a comment