[Fixed]-Is there a function that does the opposite of get_object_or_404()

1👍

No, I think django doesn’t have it is because django shouldn’t assume what’s the default value if the query is not found. Do this:

try:
    tag = Keyword.objects.get(slug=tag)
except Keyword.DoesNotExist:
    tag = None

Leave a comment