Helpers¶
-
class
ajaxviews.helpers.DateWidget(attrs=None, format=None)[source]¶ Bases:
django.forms.widgets.DateInputDjango date widget which renders a bootstrap input group addon with a calendar glyphicon around the input field.
-
ajaxviews.helpers.construct_autocomplete_searchform(autocomplete_classname)[source]¶ Construct a crispy form to display a search input field for list views using django autocomplete.
Parameters: autocomplete_classname (str) – Name of the autocompletion registered with autocomplete_light Returns: Crispy form instance
-
ajaxviews.helpers.get_objects_for_model(user, model, perm_prefix='access_')[source]¶ Shortcut to return objects of a model for an authenticated user with permissions. This uses guardians
get_objects_for_userfunction.>>> get_objects_for_model(request.user, ModelClass) <queryset>
This expects the django model module to be at the root of it’s app directory.
Parameters: - user – Authenticated user
- model – Django model instance
- perm_prefix – Default:
access_
Returns: None if no permission else QuerySet
-
ajaxviews.helpers.init_chosen_widget(field_items, disable_help_text=True)[source]¶ Add
.chosen-widgethtml class attribute to all fields of typeSelectorSelectMultiple.Parameters: - field_items – Django field items
- disable_help_text (bool) – Disable the fields help text. Default: True
-
ajaxviews.helpers.init_dateinput(field_items)[source]¶ Assing the
DateWidgetto all django fields which derive fromDateTimeBaseInputand add.dateinputto the widget’s html class attribute.Parameters: field_items (dict) – Django field items