Last active
September 27, 2019 09:11
-
-
Save kezabelle/d69c9c1fb8af48bc2b3106042d064700 to your computer and use it in GitHub Desktop.
discussing excluding nullable charfields with gcbirzan on #django IRC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> class TestModel(models.Model): | |
... test_field = models.CharField(blank=True, null=True) | |
... class Meta: | |
... app_label="test" | |
>>> TestModel.objects.exclude(test_field='').query.__str__() | |
'SELECT "test_testmodel"."id", "test_testmodel"."test_field" FROM "test_testmodel" WHERE NOT ("test_testmodel"."test_field" = AND "test_testmodel"."test_field" IS NOT NULL)' | |
>>> import django | |
>>> django.VERSION | |
(2, 2, 4, 'final', 0) | |
>>> from django.conf import settings | |
>>> settings.DATABASES | |
{'default': {'ENGINE': 'django.db.backends.sqlite3', ... }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment