Opened 8 years ago

Closed 8 years ago

#26978 closed Cleanup/optimization (invalid)

Improve the message attached to the 404 raised by get_object_or_404 and get_list_or_404

Reported by: Joachim Jablon Owned by: nobody
Component: Core (Other) Version: 1.9
Severity: Normal Keywords: 404, object_name
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Joachim Jablon)

The problem :


If no object is returned by get_object_or_404 and get_list_or_404, they raise an Http404 error for which the error message contains the model._meta.object_name. This name should not really be shown to the user within the normal workflow. Classes have a verbose_name that is more appropriate.

Moreover, this message should be translatable.

(not sure if it's really a bug report or a feature request...)

Code :


https://github.com/django/django/blob/64aba7a8aba06b8be52a1a099b44e1d3be4bdd26/django/shortcuts.py#L93

Change History (4)

comment:1 by Joachim Jablon, 8 years ago

Description: modified (diff)

comment:2 by Tim Graham, 8 years ago

Component: Error reportingCore (Other)
Owner: set to nobody
Type: UncategorizedCleanup/optimization

Is the idea that these messages might be user-facing since #24733?

comment:3 by Joachim Jablon, 8 years ago

I just realized (and tested) that the message of the Http404 was actually never shown by default. And for #24733, the fact that the view can have access to the exception does not make its message user facing. If developers decide to copy exception message to their pages, that's their responsability.

I might have been a little too fast in opening the ticket. Sorry for the noise.

comment:4 by Joachim Jablon, 8 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top