[Fixed]-Django RelatedObjectDoesNotExist error

16👍

You’re trapping except Business.DoesNotExist but that’s not the exception that’s being thrown. Per this SO answer you want to catch the general DoesNotExist exception instead.

EDIT: see comment below: the actual exceptions are being caught by DoesNotExist because they inherit from DoesNotExist. You’re better off trapping the real exception rather than suppressing any and all DoesNotExist exceptions from the involved models.

👤Tom

Leave a comment