Opened 6 years ago

Last modified 6 years ago

#29664 closed Cleanup/optimization

Need Proper error handling for CBV in urls. — at Initial Version

Reported by: Amar Owned by: emiamar@…
Component: Core (URLs) Version: 2.1
Severity: Normal Keywords:
Cc: emiamar@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When in urls.py if one misses to call as_view() (Example shown below) method django throws weird error. Need better way of handling error

Incorrect definition

urlpatterns = [
    path('admin/', admin.site.urls),
    path('hello/', HelloView)
]

Correct definition

urlpatterns = [
    path('admin/', admin.site.urls),
    path('hello/', HelloView.as_view())
]

Error

TypeError at /hello/

__init__() takes 1 positional argument but 2 were given

Request Method: 	GET
Request URL: 	http://localhost:8000/hello/
Django Version: 	2.0.7
Exception Type: 	TypeError
Exception Value: 	

__init__() takes 1 positional argument but 2 were given

Exception Location: 	/home/amar/.virtualenvs/djmongo/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response, line 126

Change History (0)

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