Opened 3 years ago

Last modified 3 years ago

#33179 closed Cleanup/optimization

Show helpful error message when first argument to shortcuts.render is not request — at Initial Version

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

Description

This is one of a class of changes I'm interested in making, so please also comment on if developer experience/error message improvements like this are wanted in general.

I recently started a new Django project and got frustrated at tiny mistakes I made that were difficult to find because of opaque error messages.

Currently, writing this:

def render_view_missing_request(request):
    return render('shortcuts/render_test.html')

leads to:

TypeError: render() missing 1 required positional argument: 'template_name'

which is very confusing because the developer did provide the template name.

Writing another common variation:

def render_view_missing_request(request):
    return render('shortcuts/render_test.html', {'foo': 'FOO'})

leads to:

TypeError: join() argument must be str or bytes, not 'dict'

which is easier to figure out given the stack trace, but still unhelpful to a newcomer.

Change History (0)

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