All Projects → cfpb → wagtail-treemodeladmin

cfpb / wagtail-treemodeladmin

Licence: CC0-1.0 license
An extension for Wagtail's ModelAdmin for a page explorer-like navigation of Django model relationships

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to wagtail-treemodeladmin

gatsby-source-wagtail
Plugin for sourcing Gatsby data from Wagtail CMS
Stars: ✭ 16 (-48.39%)
Mutual labels:  wagtail
draftjs-filters
Filter Draft.js content to preserve only the formatting you allow
Stars: ✭ 53 (+70.97%)
Mutual labels:  wagtail
wagtail textract
Text extraction for Wagtail document search
Stars: ✭ 27 (-12.9%)
Mutual labels:  wagtail
wagtail-graphql
App to automatically add GraphQL support to a Wagtail website
Stars: ✭ 37 (+19.35%)
Mutual labels:  wagtail
wagtailgridder
Wagtail Gridder is a Bootstrap 4 enabled layout for the Wagtail CMS. Grid Items are created within categories, and displayed on a Grid Index Page. The JavaScript libraries Gridder and MixItUp are included.
Stars: ✭ 59 (+90.32%)
Mutual labels:  wagtail
Django-wagtailmedium
A Medium Editor integration for the Wagtail CMS.
Stars: ✭ 17 (-45.16%)
Mutual labels:  wagtail
wagtail-import-export
UNMAINTAINED. Try wagtail-transfer, the evolution of this package: https://github.com/wagtail/wagtail-transfer/
Stars: ✭ 31 (+0%)
Mutual labels:  wagtail
wagtail-color-panel
A package that adds new panels for selecting colors, works both on regular page fields and stream field.
Stars: ✭ 29 (-6.45%)
Mutual labels:  wagtail
wagtailmath
Beautiful equations in your StreamField content
Stars: ✭ 27 (-12.9%)
Mutual labels:  wagtail
wagtailyoast
Wagtail + Yoast
Stars: ✭ 22 (-29.03%)
Mutual labels:  wagtail
localore
Wagtail-based CMS and Ansible playbooks for Localore: Finding America
Stars: ✭ 16 (-48.39%)
Mutual labels:  wagtail
react-streamfield
Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
Stars: ✭ 34 (+9.68%)
Mutual labels:  wagtail
pari
Django/Wagtail based PARI webapp
Stars: ✭ 32 (+3.23%)
Mutual labels:  wagtail
wagtail-simple-gallery
A simple gallery app for Wagtail. https://pypi.org/project/wagtail-simple-gallery/
Stars: ✭ 41 (+32.26%)
Mutual labels:  wagtail
wagtail-inventory
Search Wagtail pages by the StreamField blocks they contain
Stars: ✭ 45 (+45.16%)
Mutual labels:  wagtail
wagtail-react-project
Wagtail template with a React/Redux frontend.
Stars: ✭ 25 (-19.35%)
Mutual labels:  wagtail
wagtailcolumnblocks
Streamfield columns for Wagtail
Stars: ✭ 38 (+22.58%)
Mutual labels:  wagtail
wagtail-metadata-mixin
🔍 OpenGraph, Twitter Card and Schema.org snippet tags for Wagtail CMS pages
Stars: ✭ 42 (+35.48%)
Mutual labels:  wagtail
pipeline
The Polytechnic's content management system
Stars: ✭ 17 (-45.16%)
Mutual labels:  wagtail
wagtail-pg-search-backend
PostgreSQL full text search backend for Wagtail CMS
Stars: ✭ 22 (-29.03%)
Mutual labels:  wagtail

Wagtail-TreeModelAdmin

Build Status Coverage Status

TreeModelAdmin illustration with the books and authors example below

Wagtail-TreeModelAdmin is an extension for Wagtail's ModelAdmin that allows for a page explorer-like navigation of Django model relationships within the Wagtail admin.

Dependencies

  • Python 3.6+
  • Django 2.2 (LTS), 3.1 (current)
  • Wagtail 2.11 (LTS), <3 (current)

It should be compatible with all intermediate versions, as well. If you find that it is not, please file an issue.

Installation

  1. Install wagtail-treemodeladmin:
pip install wagtail-treemodeladmin
  1. Add treemodeladmin (and wagtail.contrib.modeladmin if it's not already) as an installed app in your Django settings.py:
INSTALLED_APPS = (
    ...
    'wagtail.contrib.modeladmin',
    'treemodeladmin',
    ...
)

Concepts

Wagtail-TreeModelAdmin allows for a Wagtail page explorer-like navigation of Django one-to-many relationships within the Wagtail admin. In doing this, it conceptualizes the Django ForeignKey relationship as one of parents-to-children. The parent is the destination to of the ForeignKey relationship, the child is the source of the relationship.

Wagtail-TreeModelAdmin is an extension of Wagtail's ModelAdmin. It is intended to be used exactly like ModelAdmin.

Usage

Quickstart

To use Wagtail-TreeModelAdmin you first need to define some models that will be exposed in the Wagtail Admin.

# libraryapp/models.py

from django.db import models


class Author(models.Model):
    name = models.CharField(max_length=255)

class Book(models.Model):
    author = models.ForeignKey(Author, on_delete=models.PROTECT)
    title = models.CharField(max_length=255)

Then create the TreeModelAdmin subclasses and register the root the tree using modeladmin_register:

# libraryapp/wagtail_hooks.py
from wagtail.contrib.modeladmin.options import modeladmin_register

from treemodeladmin.options import TreeModelAdmin

from libraryapp.models import Author, Book


class BookModelAdmin(TreeModelAdmin):
    model = Book
    parent_field = 'author'


@modeladmin_register
class AuthorModelAdmin(TreeModelAdmin):
    menu_label = 'Library'
    menu_icon = 'list-ul'
    model = Author
    child_field = 'book_set'
    child_model_admin = BookModelAdmin

Then visit the Wagtail admin. Library will be in the menu, and will give you a list of authors, and each author will have a link that will take you to their books.

API

Wagtail-TreeModelAdmin uses three new attributes on ModelAdmin subclasses to express parent/child relationships:

  • parent_field: The name of the Django ForeignKey on a child model.
  • child_field: The related_name on a Django ForeignKey.
  • child_model_admin

Any TreeModelAdmin subclass can specify both parent and child relationships. The root of the tree (either the TreeModelAdmin included in a ModelAdminGroup or the @modeladmin_registered TreeModelAdmin subclass) should only include child_* fields.

Getting help

Please add issues to the issue tracker.

Getting involved

General instructions on how to contribute can be found in CONTRIBUTING.

Licensing

  1. TERMS
  2. LICENSE
  3. CFPB Source Code Policy

Credits and references

  1. Forked from cfgov-refresh
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].