Collection¶
- class cruditor.collection.CollectionViewMixin[source]¶
Bases:
objectMixin to provide some extra default functionality to Cruditor views to make building views for a collection of data (like a Django model) even easier.
- collection_list_urlname = None[source]¶
URL name to use when linking to the list view (e.g. in breadcrumb)
- collection_add_urlname = None[source]¶
URL name to use when linking to the add view (e.g. in title buttons)
- collection_detail_urlname = None[source]¶
URL name when linking to a detail page of a item (e.g. in list table or breadcrumb)
- collection_delete_urlname = None[source]¶
URL name when linking to the delete page of a item (e.g. in change view)
- get_title()[source]¶
The method calls the
get_collection_list_titlemethod when the view is a list view. All other views rely on the default behavior of cruditor.
- get_breadcrumb_title()[source]¶
The breadcrumb title returns “Delete” for delete views, default breadcrumb for all other views.
- get_breadcrumb()[source]¶
This method creates the required breadcrumb items for the collection following some rules:
No extra items for list view
list view element when the
collection_include_list_crumbmethod is true.detail view element when the
collection_include_detail_crumbmethod is true.
- get_table_class()[source]¶
This method returns the django-tables2 Table class to use in the list view. If no class is defined, a new Table class is created (with one linked column).
- collection_include_add_titlebutton()[source]¶
If this method returns true, an “Add model verbose name” button should be included in the list view.
- collection_include_list_crumb()[source]¶
If this method returns true, the list view should be included in the breadcrumb.
- collection_include_detail_crumb()[source]¶
If this method returns true, the detail view should be included in the breadcrumb.
- get_collection_url_args()[source]¶
This helper method returns the args that are used to reverse urls for list and add views (views that don’t refer to a object/instance). By default, returns an empty tuple.
- get_collection_object_url_args()[source]¶
This helper method returns the args that are used to reverse urls for views that refer to a detail page (object/instance related views). By default returns the object PK.
- get_collection_list_title()[source]¶
Helper method to override the used collection list title. By default, just returns the class
collection_list_titleproperty.
- get_collection_list_url()[source]¶
Helper method to generate the collection list url. By default, just calls reverse with the
collection_list_urlnameproperty.
- get_collection_detail_title()[source]¶
Helper method to override the used collection detail title. By default, just returns the str-representation of the requested item.
- get_collection_detail_url()[source]¶
Helper method to generate the collection detail url for the current object. By default, calls reverse with the
collection_detail_urlnameproperty and passes the object pk to the function call.
- get_collection_add_titlebutton_label()[source]¶
Helper method to override the used button label for the “Add” title button. By default, returns “Add <model verbose name>”.
- get_collection_add_url()[source]¶
Helper method to generate the collection add url. By default, just calls reverse with the
collection_add_urlnameproperty.
- cruditor.collection.generate_urls(path_prefix, name_prefix, list_view=None, add_view=None, change_view=None, delete_view=None, extra_detail_views=None, detail_path='<int:pk>')[source]¶
This helper allows creating urls for urlpatterns in urls.py in a fast way by just providing the view classes and some url and name prefix. In addition, one can add extra detail views.