[Answer]-Django empty query not checking at None

0👍

QuerySet.get() doesn’t return None if no record is found. As the documentation says, it raises DoesNotExist. Catch the exception.

1👍

Use the first() method:

details = Details.objects.first(ipAddress=ip)

Or more suitable exists():

if Details.objects.exists(ipAddress=ip):
    ...

Leave a comment