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
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)
]
Raw data
{
"_id": null,
"home_page": "https://github.com/LilJack118/wagtail-dynamic-dropdown",
"name": "wagtail-dynamic-dropdown",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "wagtail django",
"author": "LilJack118",
"author_email": "jakub@kachange.com",
"download_url": "https://files.pythonhosted.org/packages/ab/5f/6d558f57f0d8c6750443e2fc4172b470155df2305d7bcdafc5c46d4e5903/wagtail-dynamic-dropdown-0.0.4.tar.gz",
"platform": null,
"description": "Wagtail Dynamic Dropdown\n========================\n\nA Django application which allow to use dynamically defined choices that\nwill be updated every time the user opens edit/create page. Moreover,\nthe choices are not migrated to the database.\n\nInstall\n-------\n\n::\n\n pip install wagtail-dynamic-dropdown\n\nThen add ``wagtail_dynamic_dropdown`` to your installed apps:\n\n::\n\n INSTALLED_APPS = [\n ...\n 'wagtail_dynamic_dropdown'\n ]\n\nUsage\n-----\n\n###1. Define function that will return choices\n\n.. code:: python\n\n def dynamic_choices():\n \"\"\"\n Choices creation logic\n \"\"\"\n return choices\n\nThis function should return iterable which contains list of touples.\nExample of valid choices:\n\n.. code:: python\n\n choices = (\n ('choice_1','label_1'),\n ('choice_2','label_2')\n )\n\n###2. Use your function with DynamicDropdownPanel\n\nIn your model create CharField field. Then pass its name and path to\nchoice function as arguments in DynamicDropdownPanel\n\n.. code:: python\n\n from wagtail_dynamic_dropdown.edit_handlers import DynamicDropdownPanel\n\n class MyModel():\n ...\n my_dynamic_choices = models.CharField(max_length=255, blank=True,null=True)\n\n content_panels = [\n DynamicDropdownPanel(\"my_dynamic_choices\", \"app_name.folder_name.file_name.function_name\")\n ]\n\nOr, instead of defining a function path, you can import it and pass it\nas an argument\n\n.. code:: python\n\n from wagtail_dynamic_dropdown.edit_handlers import DynamicDropdownPanel\n from app_name.folder_name.file_name import function_name\n\n class MyModel():\n ...\n my_dynamic_choices = models.CharField(max_length=255, blank=True,null=True)\n\n content_panels = [\n DynamicDropdownPanel(\"my_dynamic_choices\", function_name)\n ]\n",
"bugtrack_url": null,
"license": "",
"summary": "",
"version": "0.0.4",
"project_urls": {
"Bug Tracker": "https://github.com/LilJack118/wagtail-dynamic-dropdown/issues",
"Homepage": "https://github.com/LilJack118/wagtail-dynamic-dropdown"
},
"split_keywords": [
"wagtail",
"django"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0ee20b1c1b2033de1b54ed600beb4cc69f214354b31baa491e1cd76046a10d77",
"md5": "e44a31bfbf43ab20bea6ccd8876b075d",
"sha256": "f71644bac6403d3c1b11a903f46815fdcb98e72c013ed1570839d7eebff9288f"
},
"downloads": -1,
"filename": "wagtail_dynamic_dropdown-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e44a31bfbf43ab20bea6ccd8876b075d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13769,
"upload_time": "2023-05-27T20:53:19",
"upload_time_iso_8601": "2023-05-27T20:53:19.169717Z",
"url": "https://files.pythonhosted.org/packages/0e/e2/0b1c1b2033de1b54ed600beb4cc69f214354b31baa491e1cd76046a10d77/wagtail_dynamic_dropdown-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ab5f6d558f57f0d8c6750443e2fc4172b470155df2305d7bcdafc5c46d4e5903",
"md5": "a3a8e3173ab013d5bb41e88454b3975e",
"sha256": "d386815378684b88ce59c5b4061767b4821434c39081a365d6931ff936502ea0"
},
"downloads": -1,
"filename": "wagtail-dynamic-dropdown-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "a3a8e3173ab013d5bb41e88454b3975e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10092,
"upload_time": "2023-05-27T20:53:20",
"upload_time_iso_8601": "2023-05-27T20:53:20.888310Z",
"url": "https://files.pythonhosted.org/packages/ab/5f/6d558f57f0d8c6750443e2fc4172b470155df2305d7bcdafc5c46d4e5903/wagtail-dynamic-dropdown-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-27 20:53:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LilJack118",
"github_project": "wagtail-dynamic-dropdown",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "wagtail-dynamic-dropdown"
}