Entries tagged "Reference"

as_sql in a Django Multi-DB Environment

I've had to look for this a few times in the past few days, so I figured I should post it here.

from django.db import DEFAULT_DB_ALIAS
Foo.objects.all().query.get_compiler(DEFAULT_DB_ALIAS).as_sql()

or

Foo.objects.all().query.get_compiler('default').as_sql()

Mobify empowers marketers and developers to create amazing mobile web experiences. Tap to learn more

Mobify