When a get_object_or_404 returns a 404, it'd be nice if it would return which query didn't provide an object (when DEBUG=True)
|Reported by:||Beetle_B||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I recently had an error in a query in a context processor. When I tried to go to a certain page, I got the error:
"No CollabProject matches the given query".
And practically no other information. No trackbacks or anything. No indication of which file the error was in. Just that message and a 404.
I kept checking and couldn't find any error in my view. I even confirmed that the view executed to the end.
It was only by chance that I discovered the error in the context processor.
Isn't there a way to have it such that if the error occurs in a context processor, it can point to the line in the context processor that had the bad query?
BTW, by bad query I mean a valid query that doesn't return any objects in the database.
I suspect this may be a problem with such a query in a middleware, but did not experiment.
Change History (8)
comment:1 Changed 8 years ago by
|Patch needs improvement:||unset|
comment:2 Changed 8 years ago by
|Summary:||Errors in queries in context processors give a very unhelpful error page. → When a get_object_or_404 returns a 404, it'd be nice if it would return which query didn't provide an object (when DEBUG=True)|