Allow class based views to be included in urls.py by name as a string
|Reported by:||tanderegg||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:1 Changed 2 years ago by tanderegg
- Cc timothy.anderegg@… added
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Version changed from 1.4 to master
comment:3 Changed 2 years ago by Alex
- Resolution set to wontfix
- Status changed from new to closed