We currently use register_model_view() to register detail views (edit, delete, etc.) for models, which obviates the need to declare explicit URL paths for each. This could be extended to support list views as well. For example, a common set of views might look like this:
# List view
@register_model_view(MyModel, list=True)
class FooListView(generic.ObjectListView):
# Detail view
@register_model_view(MyModel)
class MyModelView(generic.ObjectView):
# Add/edit views
@register_model_view(MyModel, 'edit')
@register_model_view(MyModel, 'add', list=True)
class MyModelEditView(generic.ObjectEditView):
# Delete view
@register_model_view(MyModel, 'delete')
class MyModelDeleteView(generic.ObjectDeleteView):
# Bulk import view
@register_model_view(MyModel, 'import', list=True)
class MyModelBulkImportView(generic.BulkImportView):
# Bulk delete view
@register_model_view(MyModel, 'delete', list=True)
class MyModelBulkDeleteView(generic.BulkDeleteView):
The corresponding set of URL paths could then be reduced to:
Proposed Changes
We currently use
register_model_view()
to register detail views (edit, delete, etc.) for models, which obviates the need to declare explicit URL paths for each. This could be extended to support list views as well. For example, a common set of views might look like this:The corresponding set of URL paths could then be reduced to:
(This could potentially be reduced even further, but I'm also wary of over-optimizing.)
get_model_urls()
will likewise need to be extended to differentiate between list and detail views.Justification
This will allow us to reduce a substantial amount of boilerplate URL patterns without any breaking changes (AFAICT).