[ACCEPTED]-Generate Database Schema using Python-schema

Accepted answer
Score: 14

If your talking about needing to see the 5 SQL schema, run ./manage.py sqlall <appname>

If you want a visualisation 4 of the schema you can get django-extensions and run ./manage.py graph_models -a -g -o my_project.png. This 3 will produce a pretty schema graph for you, but 2 generally omits border conditions. you may 1 want to check the options to add more data. http://readthedocs.org/docs/django-extensions/en/latest/graph_models.html

Score: 5

manage.py sql <appname appname ...> (docs)

0

Score: 2

Using Your DB

As mentioned in the tutorial, you can use your database's 7 command line client to get the schema.

Example 6 using sqlite:

python manage.py dbshell
> .schema

You may need to install sqlite3 5 for this to work.

Using Django

You used to be able to 4 use python manage.py sql ..., but it has been deprecated in 1.9 3 in favor of migrations. You can check out 2 the initial migration scripts using:

python manage.py sqlmigrate myapp 0001_initial

(From 1 Answer: Equivalent of sqlall in Django 1.9?)

More Related questions