Re: My proposal to create a new exception

2020-02-09 Thread Victor Porton
Just because your code repeated in each and every form can be eliminated and we can check it all in one place, shortening code, eliminating duplication, reducing possibilities of errors. On 09/02/2020 12:45, Steven Mapes wrote: Perhaps I'm totally missing the point and use case for this but is

Re: My proposal to create a new exception

2020-02-09 Thread Steven Mapes
Perhaps I'm totally missing the point and use case for this but is there any reason you are not simply using any of these if expected_key is not in request.GET: return MyErrorResponse(...) if not request.GET.get("expected_key", None): return MyErrorResponse(...) required = ["one", "two

My proposal to create a new exception

2020-02-08 Thread Victor Porton
In https://code.djangoproject.com/ticket/31239 I proposed to create QueryDictKeyError derived from MultiValueDictKeyError and raise this exception on a missing parameter in request.GET and request.POST. It is to be done to handle error in user data easily: try: x = request.GET['x'] except Mult