Is there a way to do the following in one call:
Model.objects.get(id=1) else None
The only way I found a way to do this is to do:
try:
object = Model...
except:
object = None
Is there a way to do this in one call in django?
Refresh . It doesn't seem like it is like in a block try/except, but here is the best answer: In Django, how do I object.get, but return None when nothing is found?
source
share