#33179: Show helpful error message when first argument to shortcuts.render is
not
request
-----------------------------------------+--------------------------
Reporter: Joel Sleppy | Owner: nobody
Type: New feature | Status: assigned
Component: Uncategorized | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+--------------------------
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:
{{{
#!python
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:
{{{
#!python
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33179>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.61c8cc1fe06fadd82516a51fb7218d31%40djangoproject.com.