Django Toggled Widgets
This package makes it possible to toggle between fields in the Django admin. When a form containing toggled fields is submitted, any field that did not have visibility upon submission is automatically set empty in the cleaned data.
Usage
-
Add "toggled_widgets" to your `INSTALLED_APPS setting.
-
Add
toggled_widgets.ToggledWidgetFormMixinto the MRO of any form class that requires the toggle behavior. -
Set the form class'
toggle_groupsattribute to an iterable of tuples that describe the toggle relationship. -
Add `toggled_widgets.ToggledWidgetAdminMixin to the MRO of any model admin class that uses a form containing the toggle behavior.
-
Optionally add
toggled_widgets.ToggledWidgetMixinto the MRO of the toggled widget classes in order to gain more control over the appearance of the toggle control (e.g. by defining themetafield_labelto customize the toggle control's label).
ModelForm configuration
In the simplest implementation, each element in the tuples contained in the form class' toggle_groups attribute is a string whose value is a field name. The admin form will provide a control to toggle between these fields. For example:
class SomeModelForm(ToggledWidgetFormMixin, ModelForm):
toggle_groups = [
('some_field', 'some_other_field')
]
Any element in the tuple may also be an iterable containing multiple field names. In this case, any field name past the first in this iterable will toggle sympathetically along with the field named in the first item.
class SomeModelForm(ToggledWidgetFormMixin, ModelForm):
toggle_groups = [
('some_field', ('some_other_field', 'some_third_field'))
]
Release files for django-toggled-widgets 0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-toggled-widgets-0.8.tar.gz | 21.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_toggled_widgets-0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.9 kB
Release files / django-toggled-widgets-0.8.tar.gz
| Download URL | django-toggled-widgets-0.8.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
780b82fd18a6c1d8e4341be15698d45f074ffc410a679469efe1d18c85434242
|
|
BLAKE2b-256 checksum How to use checksums |
56b32fd1783ad7f02a04d7b4c53b9112db1a4cf9623e89b720c087ec6532a669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13
|
Release files / django_toggled_widgets-0.8-py3-none-any.whl
| Download URL | django_toggled_widgets-0.8-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
403fb71aa12ea08f7e84a85c2dc29811749bff9cd63e0353bbe87d1e8f5d9a1c
|
|
BLAKE2b-256 checksum How to use checksums |
55326bc541b7ed605fd9aefd7aebe71c916e8c37117a0f3d317ded97f278fa57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13
|