Allow class based views to be included in urls.py by name as a string
|Reported by:||Tim Anderegg||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Class based views currently have to be imported into urls.py and then added to urlpatterns using ClassBasedView.as_view().
It would be relatively trivial, it seems, to add functionality to the method 'get_callable' in django.core.urlresolvers that uses inspect.isclass to determine if the lookup_view refers to a class, and if so set lookup_view = lookup_view.as_view(), throwing an exception if lookup_view is a class but the method as_view() doesn't exist.
This would help cleanup urls.py when using class based views, and be more consistent with how function based views are handled. Is there any reason not to do this? If people support this I will submit a patch.
Change History (5)
comment:3 Changed 4 years ago by
|Status:||new → closed|