I have been tripping over the following exception
DoesNotExist: INSERT_YOUR_MODEL_NAME_HERE matching query does not exist.

The error is source in django 1.11.2 in db.models query.py file, in the 
get(self, *args, **kwargs) function, line 378 to be exact
...
    raise self.model.DoesNotExist(...)
...
This throws a 500 error and I would like my code not to throw a 500 error 
in this situation, rather a customized message more along a 4xx error e.g.
{"message": "record matching identifier A and identifier B not found in 
database"}
rather than a 500 error.

It seems to me that my only choice right now is to subclass QuerySet and 
write my own version of the get(self, *args, **kwargs) method. Is that my 
only choice or is there a django parameter I can set so that 0 matching 
results does not return a 500?

Or do I need to intercept the 500 error somewhere else.

Sorry, am a bit of a newbie to django internals, all help and advice is 
appreciated.

Thanks,
Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/499aad32-3e2d-4717-97cb-f65feccc0d65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to