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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b13475ad104fdb4354effd1319b3b2012ca126f219f9952404a9c444f88c998 |
|
MD5 | 7f951580fd5c57527a4a18eee430ded9 |
|
BLAKE2b-256 | 2c138112af7f0b6cdad14ceeb98c9ec72d94d0bcdaf4beb157e69f2b323cc18e |
Close
Hashes for wagtail_modelchooser-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8f7bf491f305ce1e97ef6559df18f734edf794f006ac9cd50b6b1e4a60076b4 |
|
MD5 | 2be3790d2eb1fb2659d30f5afaecb738 |
|
BLAKE2b-256 | 3079ff504bc4869631801eaac6771a5f9d0113c234eda518f2e4fe5f7de8d421 |