-1

I have see some code of everybody on here. But it's still difficult, and lost a ton of time. Have some way to do this ? Thank you, love all.

Secret man
  • 23
  • 7
  • Possible duplicate of [How can I see the raw SQL queries Django is running?](https://stackoverflow.com/questions/1074212/how-can-i-see-the-raw-sql-queries-django-is-running) – Pynchia Oct 17 '19 at 02:51

2 Answers2

0

You can use django.db.backends log to log the sql queries. Set this on your settings.py:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
        }
    },
    'loggers': {
        'django.db.backends': {
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    }
}
Toan Quoc Ho
  • 3,266
  • 1
  • 14
  • 22
0

you can use :

python manage.py sqlmigrate (name_your_app)(your_number_at_migrations_folder)

Ex: python manage.py sqlmigrate blog 0001

Community
  • 1
  • 1
Quang Tu
  • 44
  • 1
  • 6