Answers for "how to check if an entry exists in a model django"

0

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
Posted by: Guest on April-29-2021

Code answers related to "how to check if an entry exists in a model django"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language