Skip to content

Instantly share code, notes, and snippets.

@camelcaseblog
Last active January 29, 2019 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camelcaseblog/360bd39713974b3aa9fd4d3ad234bb5a to your computer and use it in GitHub Desktop.
Save camelcaseblog/360bd39713974b3aa9fd4d3ad234bb5a to your computer and use it in GitHub Desktop.
ORM NULL
>>> class Reporter(models.Model):
... id = models.AutoField(primary_key=True, null=False)
... name = models.TextField
...
>>> qs = Reporter.objects.filter(name=None) # 1
>>> print(qs.query)
SELECT *
FROM reporter
WHERE name = NULL
>>> qs = Reporter.objects.filter(name__isnull=True) # 2
>>> print(qs.query)
SELECT *
FROM reporter
WHERE name IS NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment