14

I want to generate a basic DB schema for my django project to display all my Apps with Models and Model Fields with boundary conditions etc. Is there already any DB schema generator for django in python? Or otherwise how should i go about doing it.

3 Answers 3

15

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

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

Sign up to request clarification or add additional context in comments.

Comments

5

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

Comments

1

Using Your DB

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

Example using sqlite:

python manage.py dbshell
> .schema

You may need to install sqlite3 for this to work.

Using Django

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

python manage.py sqlmigrate myapp 0001_initial

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.