[Answer]-Django generic UpdateView: Getting the object to be updated

1👍

You could do the get in your get_object method, allow a DoesNotExist error to propagate (don’t catch it), and override the dispatch method and catch the DoesNotExist exception there. From dispatch, you can return a redirect.

Something like:

def dispatch(...):
    try:
         return super(...)  # call superclass dispatch
    except Model.DoesNotExist:
         return ... your redirection ...

Leave a comment