how to check if an entry exists in a model django code example
Example: how to check if an entry exists in a model django
try:
obj = model1.objects.get(pk=20)
except DoesNotExist:
#do something
Else ----
if model1.objects.filter(pk=20).exists():
#do something
else:
#do otherthing