https://stackoverflow.com/questions/3090302/how-do-i-get-the-object-if-it-exists-or-none-if-it-does-not-exist-in-django
fitler.first() :
Content.objects.filter(name="baby").first()
try and catch():try:
go = SomeModel.objects.get(foo='bar')
except SomeModel.DoesNotExist:
go = None
No comments:
Post a Comment