manage.py sql command for django models - Django
Asked Answered
S

2

3

just wondering... but is it possible to generate SQL commands for django's models?

e.g. the session model

python manage.py sql django

Any ideas?

Slush answered 22/11, 2010 at 14:24 Comment(0)
V
8

You need to mention the name of the specific app that comes with django, such as

 python manage.py sql auth
 python manage.py sql admin

I find it a bit clumsy that you can't give fully-qualified names (such as django.contrib.auth), but using just the last part of the name seems to work fine.

Valonia answered 22/11, 2010 at 14:47 Comment(0)
R
2

This is no longer possible with django migrations (django>=1.7). The sql management command is no longer available.

Though it operates slightly differently, the sqlmigrate management command can be used to find the sql commands for individual migrations.

./manage.py sqlmigrate auth  0001
./manage.py sqlmigrate auth  0002
...
Recession answered 6/1, 2017 at 16:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.