{"id":22403332,"url":"https://github.com/springload/wagtailmodelchoosers","last_synced_at":"2025-10-24T05:45:08.222Z","repository":{"id":12210864,"uuid":"62670953","full_name":"springload/wagtailmodelchoosers","owner":"springload","description":"A Wagtail app to pick generic models (rather than snippets or pages)","archived":false,"fork":false,"pushed_at":"2023-06-27T23:36:17.000Z","size":1177,"stargazers_count":24,"open_issues_count":16,"forks_count":7,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-11-07T05:09:53.838Z","etag":null,"topics":["modelchooser","wagtail"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/springload.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-05T21:30:32.000Z","updated_at":"2024-05-29T08:47:22.000Z","dependencies_parsed_at":"2024-06-19T02:49:01.374Z","dependency_job_id":"61575013-639f-4519-8c7d-ff512ae3ef38","html_url":"https://github.com/springload/wagtailmodelchoosers","commit_stats":{"total_commits":20,"total_committers":4,"mean_commits":5.0,"dds":0.65,"last_synced_commit":"39e32d43295ace6d5c9802f88a58ddad84acff8b"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springload%2Fwagtailmodelchoosers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springload%2Fwagtailmodelchoosers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springload%2Fwagtailmodelchoosers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springload%2Fwagtailmodelchoosers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/springload","download_url":"https://codeload.github.com/springload/wagtailmodelchoosers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228267806,"owners_count":17893841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["modelchooser","wagtail"],"created_at":"2024-12-05T09:16:49.302Z","updated_at":"2025-10-24T05:45:08.168Z","avatar_url":"https://github.com/springload.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://travis-ci.org/springload/wagtailmodelchoosers.svg?branch=master\n   :target: https://travis-ci.org/springload/wagtailmodelchoosers\n.. image:: https://img.shields.io/pypi/v/wagtailmodelchoosers.svg\n   :target: https://pypi.python.org/pypi/wagtailmodelchoosers\n   \nwagtailmodelchoosers\n====================\n\n    A Wagtail app to pick generic models (rather than snippets or pages).\n\n**This is alpha software, use at your own risk. Do not use in production (yet).**\n\nCheck out `Awesome Wagtail \u003chttps://github.com/springload/awesome-wagtail\u003e`_ for more awesome packages and resources from the Wagtail community.\n\n.. image:: https://cdn.rawgit.com/springload/wagtailmodelchoosers/b7b6202/.github/wagtailmodelchoosers-screenshot.png\n   :width: 728 px\n\nInstallation\n------------\n\nGrab the package from pip with ``pip install wagtailmodelchoosers``, then add ``wagtailmodelchoosers`` in ``INSTALLED_APPS`` in your settings.\n\nUsage\n-----\n\n``ModelChooserBlock`` takes the name of the chooser configuration as first positional argument. Use other block kwargs (e.g. `required`) as usual.\n\n.. code:: python\n\n    from wagtail.wagtailcore import blocks\n    from wagtailmodelchoosers.blocks import ModelChooserBlock\n    \n    class CustomBlock(blocks.StructBlock):\n        custom_model = ModelChooserBlock('custom_model')  # `chooser` can be a positional argument, the keyword is used here for clarity.\n       \n``ModelChooserPanel`` takes the name of the field as first positional argument (like a regular Panel) and the name of the chooser configuration as second positional argument. Use other panel kwargs as usual.\n\n.. code:: python\n\n    from django.db import models\n    from wagtail.core.models import Page\n    from wagtailmodelchoosers.edit_handlers import ModelChooserPanel\n    \n    class CustomPage(Page):\n        custom_model = models.ForeignKey('myapp.CustomModel')\n        \n        panels = [\n            ...\n            ModelChooserPanel('custom_model', chooser='custom_model'),  # `chooser` can be a positional argument, the keyword is used here for clarity.\n        ]\n\nTo select a model from a remote API, respectively use ``RemoteModelChooserBlock`` and ``RemoteModelChooserPanel`` instead.\n\nIf you have `WagtailDraftail \u003chttps://github.com/springload/wagtaildraftail\u003e`_ installed, it will automatically register the ``ModelSource`` and ``RemoteModelSource`` to the JS. Refer to ``WagtailDraftail``'s `documentation \u003chttps://github.com/springload/wagtaildraftail#configuration\u003e`_ to hook it up properly.\n\nConfiguration\n~~~~~~~~~~~~~\n\nIt looks for a ``MODEL_CHOOSERS_OPTIONS`` dictionary in the settings where the key is the name of the chooser and the value, a dictionary of options.\n\nThe ModelChooser and RemoteModelChooser share a similar base configuration and only have a few specific fields.\n\n.. code:: python\n\n    MODEL_CHOOSERS_OPTIONS = {\n        'navigation': {\n            'label': 'Navigation',                                   # The label to use for buttons or modal title\n            'display': 'name',                                       # The field to display when selecting an object\n            'list_display': [                                        # The fields to display in the chooser\n                {'label': 'Name', 'name': 'name'},\n                {'label': 'Identity', 'name': 'identity'},\n                {'label': 'Active', 'name': 'active'},\n            ],\n            'content_type': 'core.Navigation',                       # ONLY FOR MODEL: The django content type of the model\n            'fields_to_save': ['id'] + RATE_CHOOSER_DISPLAY_FIELDS,  # ONLY FOR REMOTE: The remote objects fields to save to the DB. Leave empty to save the whole object.\n            'remote_endpoint': 'http://...'                          # ONLY FOR REMOTE: The remote API endpoint.\n            'pk_name': 'uuid',                                       # The primary key name of the model\n        }\n    }\n    \nIn addition, you can customise the mapping of the key of the API, see the configuration key names being used for the `query \u003chttps://github.com/springload/wagtailmodelchoosers/blob/c36bb877eef4ac4af6b221f0d7ff7416354754c7/wagtailmodelchoosers/utils.py#L107-L112\u003e`_ and the `response \u003chttps://github.com/springload/wagtailmodelchoosers/blob/c36bb877eef4ac4af6b221f0d7ff7416354754c7/wagtailmodelchoosers/utils.py#L115-L123\u003e`_.\n\n\nDevelopment\n-----------\n\nInstallation\n~~~~~~~~~~~~\n\nRequirements: ``virtualenv``, ``pyenv``, ``twine``\n\n.. code:: sh\n\n    git clone git@github.com:springload/wagtailmodelchoosers.git\n    cd wagtailmodelchoosers/\n    virtualenv .venv\n    source ./.venv/bin/activate\n    pip install -e .[testing,docs] -U\n    nvm install\n    npm install\n\nCommands\n~~~~~~~~\n\n.. code:: sh\n\n    make help            # See what commands are available.\n\nTODO: Complete\n\nReleases\n~~~~~~~~\n\n*  Make a new branch for the release of the new version.\n*  Update the `CHANGELOG \u003chttps://github.com/springload/wagtailmodelchoosers/CHANGELOG.md\u003e`_.\n*  Update the version number in ``wagtailmodelchoosers/__init__.py`` and ``package.json``, following semver.\n*  Make a PR and squash merge it.\n*  Back on master with the PR merged, use ``make publish`` (confirm, and enter your password).\n*  Finally, go to GitHub and create a release and a tag for the new version.\n*  Done!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringload%2Fwagtailmodelchoosers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspringload%2Fwagtailmodelchoosers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringload%2Fwagtailmodelchoosers/lists"}