Opened 8 years ago

Closed 8 years ago

#27071 closed Cleanup/optimization (wontfix)

Raise a friendly exception when a string is returned from a view function

Reported by: Rushi Agrawal Owned by:
Component: HTTP handling Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

The error currently is:

AttributeError at <url>
'str' object has no attribute 'get'

The stacktrace printed is also equally inscrutable. I think we can be a little bit more thorough in checking return type ("if return type is a string, show our custom message), and avoid somebody googling/stackoverflowing for this issue instead of understanding the problem right away.

Change History (2)

comment:1 by Tim Graham, 8 years ago

I'm not sure if imposing a type check performance penalty on every response is worth it.

comment:2 by Tim Graham, 8 years ago

Component: Error reportingHTTP handling
Resolution: wontfix
Status: newclosed
Summary: Usability: We should be more precise when someone returns a string from a view function and not HttpResponse objectRaise a friendly exception when a string is returned from a view function

I'm not sure if the mistake is common enough to warrant a check on every response, though there is a check for None being returned. If you'd like to, feel free to raise the idea on the DevelopersMailingList to get other opinions.

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