Opened 8 years ago

Last modified 8 years ago

#26978 closed Cleanup/optimization

Improve the message attached to the 404 raised by get_object_or_404 and get_list_or_404 — at Initial Version

Reported by: Joachim Jablon Owned by:
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

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 or a feature...)

Code :


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

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top