No project description provided
Project description
Wagtail Dynamic Dropdown
A Django application which allow to use dynamically defined choices that will be updated every time the user opens edit/create page. Moreover, the choices are not migrated to the database.
Install
::
pip install wagtail-dynamic-dropdown==0.0.1
Then add wagtail_dynamic_dropdown
to your installed apps:
::
INSTALLED_APPS = [ ... 'wagtail_dynamic_dropdown' ]
Usage
###1. Define function that will return choices
.. code:: python
def dynamic_choices(): """ Choices creation logic """ return choices
This function should return iterable which contains list of touples. Example of valid choices:
.. code:: python
choices = ( ('choice_1','label_1'), ('choice_2','label_2') )
###2. Use your function with DynamicDropdownPanel
In your model create CharField field. Then pass its name and path to choice function as arguments in DynamicDropdownPanel
.. code:: python
from wagtail_dynamic_dropdown.edit_handlers import DynamicDropdownPanel
class MyModel(): ... my_dynamic_choices = models.CharField(max_length=255, blank=True,null=True)
content_panels = [
DynamicDropdownPanel("my_dynamic_choices", "app_name.folder_name.file_name.function_name")
]
Or, instead of defining a function path, you can import it and pass it as an argument
.. code:: python
from wagtail_dynamic_dropdown.edit_handlers import DynamicDropdownPanel from app_name.folder_name.file_name import function_name
class MyModel(): ... my_dynamic_choices = models.CharField(max_length=255, blank=True,null=True)
content_panels = [
DynamicDropdownPanel("my_dynamic_choices", function_name)
]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for wagtail-dynamic-dropdown-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70b5483d324b3114993fdee9b8d34dbbce840af388a1cfa5fff44d91b05b59da |
|
MD5 | a96686f0da88a016b1a9af73f44628f9 |
|
BLAKE2b-256 | 080bc1cbc068421f53081a54382d3c1ba6b454d3dec1a2e2cb700bb1bc39413f |
Hashes for wagtail_dynamic_dropdown-0.0.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 644acc5fd34cabc3e067c77300ed1fa5548e09357124afcd3e9eef66be395303 |
|
MD5 | 66db1c465ee5c34c809c4d84c470e972 |
|
BLAKE2b-256 | e6d0c50f4d76124bd3067b9b7f450f93393bb0ec3c4b3d91925116c9711a5274 |