#24707: urls: error messages for broken views are better for
deprecated-old-style
than they are for new-style
-------------------------------+--------------------
Reporter: hjwp | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
I found this out while updating my book to 1.8. It's a tiny thing really,
but if you've accidentally made an uncallable view function, eg:
{{{#!python
# views.py:
my_view = None
}}}
Contrast the behaviour of urls.py if you import it old-style and new-
style:
{{{#!python
# urls.py:
from myapp import views
urlpatterns = [
url(r'/new-style-url', views.my_view)
url(r'/old-style-url', 'my_app.views.my_view')
]
}}}
Attempting to use the dot-notation gives a helpful error message:
{{{#!python
>>> resolve('/old-style-url')
[...]
ViewDoesNotExst: Could not import 'my_app.views.my_view'. View is not
callable."
}}}
But the new-style one is rather cryptic:
Attempting to
{{{#!python
>>> resolve('/whatever')
[...]
AttributeError: 'NoneType' object has no attribute 'rindex'
}}}
It's a shame the deprecated, old-style version has better UX than the new-
style! I think it's a simple fix tho, I am working on a PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/24707>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.ede892ba8aebf56b11aa6ef3b2894bd0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.