apis_core.relations.forms#
Submodules#
Package Contents#
Classes#
This form overrides generic form for relation editing. Relations have generic relations to subj and obj, but we hide those ForeignKey form fields and instead show autocomplete choices fields. In addition, one can pass a hx_post_route argument to the form to make the form set the hx-post attribute to the given value. We also pass a reverse boolean, wich gets passed on to the htmx POST endpoint using url parameters (the endpoint can then select the success_url based on the reverse state). |
|
FilterSet form for relations based on GenericFilterSetForm. Excludes relation_ptr from the columns selector |
API#
- class apis_core.relations.forms.RelationForm(*args, **kwargs)#
Bases:
apis_core.generic.forms.GenericModelFormThis form overrides generic form for relation editing. Relations have generic relations to subj and obj, but we hide those ForeignKey form fields and instead show autocomplete choices fields. In addition, one can pass a hx_post_route argument to the form to make the form set the hx-post attribute to the given value. We also pass a reverse boolean, wich gets passed on to the htmx POST endpoint using url parameters (the endpoint can then select the success_url based on the reverse state).
Initialization
Initialize the form and replace subj_object_id and obj_object_id fields with a autocomplete widget.
- clean() dict#
subj_object_id and obj_object_id can either come from initial values or from the autocomplete. In the former case, the values are simply the primary keys, which is what we want. In the latter case, the values are object instances and we want to set them to the primary keys instead.
- property relation_name: str#
A helper method to access the correct name of the relation
- class apis_core.relations.forms.RelationFilterSetForm(*args, **kwargs)#
Bases:
apis_core.generic.forms.GenericFilterSetFormFilterSet form for relations based on GenericFilterSetForm. Excludes relation_ptr from the columns selector
Initialization
- columns_exclude = ['relation_ptr']#