How do I get the object if it exists, or None if it does not exist in Django?

When I ask the model manager to get an object, it raises DoesNotExist when there is no matching object.

go = Content.objects.get(name="baby")

Instead of DoesNotExist, how can I have go be None instead?

← Назад к списку