django_choices_js API¶
apps¶
forms¶
- class django_choices_js.forms.ChoicesJsMixin(choices_opts: dict = None, *args, **kwargs)[source]¶
Bases:
objectThe base class of all Choices.js widgets.
This adds the media property that includes all necessary css and js tags for Choices.js.
- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- property media¶
- class django_choices_js.forms.ChoicesJsTextInput(choices_opts: dict = None, *args, **kwargs)[source]¶
Bases:
ChoicesJsMixin,TextInputA widget for text input that allows multiple entries separated by a delimiter (default
',').Example:
text = django.forms.CharField(widget=django_choices_js.ChoicesJsTextInput, choices_opts={'maxItemCount': 3})
- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- property media¶
- class django_choices_js.forms.ChoicesJsSelect(choices_opts: dict = None, *args, **kwargs)[source]¶
Bases:
ChoicesJsMixin,Select- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- property media¶
- class django_choices_js.forms.ChoicesJsSelectMultiple(choices_opts: dict = None, *args, **kwargs)[source]¶
Bases:
ChoicesJsMixin,SelectMultiple- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- property media¶
- class django_choices_js.forms.ChoicesJsModelMixin(choices_opts=None, autocomplete_name=None, *args, **kwargs)[source]¶
Bases:
ChoicesJsMixin- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- class django_choices_js.forms.ChoicesJSModelSelect(choices_opts=None, autocomplete_name=None, *args, **kwargs)[source]¶
Bases:
ChoicesJsModelMixin,Select- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- property media¶
- class django_choices_js.forms.ChoicesJSModelSelectMultiple(choices_opts=None, autocomplete_name=None, *args, **kwargs)[source]¶
Bases:
ChoicesJsModelMixin,SelectMultiple- Parameters:
choices_opts (dict) – Options that are passed directly to the Choices.js constructor.
- property media¶
models¶
- class django_choices_js.models.ChoicesAutocompletePathConfig(path: str, fields: dict[str, list[Literal['exact', 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith', 'regex', 'iregex']]], permission: str | None)[source]¶
Bases:
object
- django_choices_js.models.autocomplete_path_for_model(model: Model, name: str | None = None)[source]¶
- django_choices_js.models.autocomplete_model(fields: list[str] | dict[str, list[Literal['exact', 'iexact', 'contains', 'icontains', 'startswith', 'istartswith', 'endswith', 'iendswith', 'regex', 'iregex']]], name: str | None = None, permission: str | None = None)[source]¶
Decorator that registers an autocompletion endpoint for a given model.
- Parameters:
fields – The fields that should be searched for autocompletion. Can be either a list of field names or a dict with field names as keys and a list of lookup functions as values. If a list is passed, icontains will be used as the default lookup function.
name – Optional identifier for the autocomplete path. If None, it will become the default path for the model.
permission – Required django permission to use the autocompletion endpoint. If None, it will be accessible to everyone.
Examples:
@autocomplete_model(fields=['name']) @autocomplete_model(fields={'name': ['istartswith', 'iendswith']}, name='prefix_or_suffix')