Django Commands: python manage.py sql your_app
python manage.py sql your_app command prints what SQL Django thinks is required to generate your database tables to the screen. You can copy and paste this SQL into your database prompt to commit the SQL to the database.
python manage.py sql your_app command is smart enough to automatically generate the proper database table creation commands, using the correct syntax. The names of the tables are your app name followed by an underscore and your lowercase model name. For example:
You can edit this, it is just the naming convention that Django defaults to.
By default, a primary key field is also added to the tables automatically (this can be changed). The name of this field is
id. If there is a foreign key field in your table, Django will append
_id to the field name by default (this can be changed). If you are using SQLite, the foreign key relationship is made explicit using a
The field types are automatically choosen based upon your database-type (SQLite, MySQL, PostgreSQL, Oracle, etc.). And your feild names are either single-quoted or double-quoted based on your database type.