All Projects → springload → wagtailmodelchoosers

springload / wagtailmodelchoosers

Licence: MIT license
A Wagtail app to pick generic models (rather than snippets or pages)

Programming Languages

python
139335 projects - #7 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
Makefile
30231 projects
HTML
75241 projects

Projects that are alternatives of or similar to wagtailmodelchoosers

Awesome Wagtail
A curated list of awesome packages, articles, and other cool resources from the Wagtail community.
Stars: ✭ 1,527 (+6539.13%)
Mutual labels:  wagtail
django-hyper-editor
Django Integration of Hyper Editor
Stars: ✭ 29 (+26.09%)
Mutual labels:  wagtail
wagtail-redirect-importer
Note: This library is now included in Wagtail 2.10, use the builtin version instead of this.
Stars: ✭ 15 (-34.78%)
Mutual labels:  wagtail
Wagtail
A Django content management system focused on flexibility and user experience
Stars: ✭ 11,387 (+49408.7%)
Mutual labels:  wagtail
Wagalytics
A Google Analytics dashboard in your Wagtail admin
Stars: ✭ 176 (+665.22%)
Mutual labels:  wagtail
wagtail-headless-preview
Previews for headless Wagtail setups
Stars: ✭ 99 (+330.43%)
Mutual labels:  wagtail
Reddit Wallpaper Changer
Reddit Wallpaper Changer
Stars: ✭ 96 (+317.39%)
Mutual labels:  wagtail
wagtail-sharing
Easier sharing of Wagtail drafts
Stars: ✭ 46 (+100%)
Mutual labels:  wagtail
wagtailcommonblocks
Common StreamField blocks for Wagtail
Stars: ✭ 40 (+73.91%)
Mutual labels:  wagtail
vagrant-wagtail-develop
A script to painlessly set up a Vagrant environment for development of Wagtail
Stars: ✭ 36 (+56.52%)
Mutual labels:  wagtail
Wagtailmedia
A Wagtail module for managing video and audio files within the admin
Stars: ✭ 128 (+456.52%)
Mutual labels:  wagtail
Consumerfinance.gov
Django project protecting American consumers
Stars: ✭ 164 (+613.04%)
Mutual labels:  wagtail
digihel
City of Helsinki Digital Helsinki Wagtail CMS
Stars: ✭ 19 (-17.39%)
Mutual labels:  wagtail
Wagtail Pipit
Pipit is a Wagtail CMS boilerplate which aims to provide an easy and modern developer workflow with a React-rendered frontend.
Stars: ✭ 109 (+373.91%)
Mutual labels:  wagtail
wagtaildraftail
🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
Stars: ✭ 23 (+0%)
Mutual labels:  wagtail
Wagtailtrans
A Wagtail add-on for supporting multilingual sites
Stars: ✭ 103 (+347.83%)
Mutual labels:  wagtail
freeturn
Freelance mission control
Stars: ✭ 50 (+117.39%)
Mutual labels:  wagtail
wagtail-filepreviews
Extend Wagtail's Documents with image previews and metadata from FilePreviews
Stars: ✭ 21 (-8.7%)
Mutual labels:  wagtail
WF-website
Website for Western Friend, part of the Religious Society of Friends
Stars: ✭ 34 (+47.83%)
Mutual labels:  wagtail
wagtailenforcer
The Wagtail arm of the law - enforce security protocols on your Wagtail site
Stars: ✭ 43 (+86.96%)
Mutual labels:  wagtail
https://travis-ci.org/springload/wagtailmodelchoosers.svg?branch=master

wagtailmodelchoosers

A Wagtail app to pick generic models (rather than snippets or pages).

This is alpha software, use at your own risk. Do not use in production (yet).

Check out Awesome Wagtail for more awesome packages and resources from the Wagtail community.

https://cdn.rawgit.com/springload/wagtailmodelchoosers/b7b6202/.github/wagtailmodelchoosers-screenshot.png

Installation

Grab the package from pip with pip install wagtailmodelchoosers, then add wagtailmodelchoosers in INSTALLED_APPS in your settings.

Usage

ModelChooserBlock takes the name of the chooser configuration as first positional argument. Use other block kwargs (e.g. required) as usual.

from wagtail.wagtailcore import blocks
from wagtailmodelchoosers.blocks import ModelChooserBlock

class CustomBlock(blocks.StructBlock):
    custom_model = ModelChooserBlock('custom_model')  # `chooser` can be a positional argument, the keyword is used here for clarity.

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.

from django.db import models
from wagtail.core.models import Page
from wagtailmodelchoosers.edit_handlers import ModelChooserPanel

class CustomPage(Page):
    custom_model = models.ForeignKey('myapp.CustomModel')

    panels = [
        ...
        ModelChooserPanel('custom_model', chooser='custom_model'),  # `chooser` can be a positional argument, the keyword is used here for clarity.
    ]

To select a model from a remote API, respectively use RemoteModelChooserBlock and RemoteModelChooserPanel instead.

If you have WagtailDraftail installed, it will automatically register the ModelSource and RemoteModelSource to the JS. Refer to WagtailDraftail's documentation to hook it up properly.

Configuration

It 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.

The ModelChooser and RemoteModelChooser share a similar base configuration and only have a few specific fields.

MODEL_CHOOSERS_OPTIONS = {
    'navigation': {
        'label': 'Navigation',                                   # The label to use for buttons or modal title
        'display': 'name',                                       # The field to display when selecting an object
        'list_display': [                                        # The fields to display in the chooser
            {'label': 'Name', 'name': 'name'},
            {'label': 'Identity', 'name': 'identity'},
            {'label': 'Active', 'name': 'active'},
        ],
        'content_type': 'core.Navigation',                       # ONLY FOR MODEL: The django content type of the model
        '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.
        'remote_endpoint': 'http://...'                          # ONLY FOR REMOTE: The remote API endpoint.
        'pk_name': 'uuid',                                       # The primary key name of the model
    }
}

In addition, you can customise the mapping of the key of the API, see the configuration key names being used for the query and the response.

Development

Installation

Requirements: virtualenv, pyenv, twine

git clone [email protected]:springload/wagtailmodelchoosers.git
cd wagtailmodelchoosers/
virtualenv .venv
source ./.venv/bin/activate
pip install -e .[testing,docs] -U
nvm install
npm install

Commands

make help            # See what commands are available.

TODO: Complete

Releases

  • Make a new branch for the release of the new version.
  • Update the CHANGELOG.
  • Update the version number in wagtailmodelchoosers/__init__.py and package.json, following semver.
  • Make a PR and squash merge it.
  • Back on master with the PR merged, use make publish (confirm, and enter your password).
  • Finally, go to GitHub and create a release and a tag for the new version.
  • Done!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].