Model choosers for Wagtail admin
Project description
A plugin for Wagtail that provides a ModelChooserPanel and ModelChooserBlock for arbitrary models.
Installing
Install using pip:
pip install wagtail-modelchooser
Then add it to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
'wagtailmodelchooser',
# ...
]
It works with Wagtail 1.4 and upwards.
Quick start
To enable the chooser for your model, you must register the model. For simple cases, decorate your model with @register_model_chooser:
from django.db import models
from wagtailmodelchooser import register_model_chooser
@register_model_chooser
class Author(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
# The ``str()`` of your model will be used in the chooser
return self.name
You can then use either ModelChooserPanel in an edit handler definition, or ModelChooserBlock in a StreamField definition:
from wagtail.wagtailcore.blocks import RichTextBlock
from wagtail.wagtailcore.fields import StreamField
from wagtail.wagtailcore.models import Page
from wagtail.wagtailadmin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtailmodelchooser.blocks import ModelChooserBlock
from wagtailmodelchooser.edit_handlers import ModelChooserPanel
class Book(Page):
name = models.CharField(max_length=255)
author = models.ForeignKey(Author)
content_panels = [
FieldPanel('name'),
ModelChooserPanel('author'),
]
class ContentPage(Page):
body = StreamField([
('text', RichTextBlock()),
('author', ModelChooserBlock('books.Author')),
])
content_panels = [
StreamFieldPanel('body'),
]
Project details
Release history Release notifications | RSS feed
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
Close
Hashes for wagtail-modelchooser-0.3.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5731916efff70ae0f07ea1dceeb18a38042b612fb3ed1d7b8db525329f13e86 |
|
MD5 | 063f69ffaf07e9304fbfff2e60bd39a0 |
|
BLAKE2b-256 | 241bfe06756cdc7d5d5be20190566502f3d4f8d4851898f4686e46c2655127dd |
Close
Hashes for wagtail_modelchooser-0.3.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e56f0c0060f66b15e800a814eb115a9cdc631366ba8e78bba5c372f678507959 |
|
MD5 | d3a1c5bd5faa1127f75a39e78958e421 |
|
BLAKE2b-256 | de9cbdb29cff7d322964f6a500087632710186b18f35bf931d20207733f74222 |