Skip to main content

Copyable ModelAdmins for Django models used on Wagtail Sites

Project description

Wagtail CopyableModelAdmin

Build Status Coverage Status

CopyableModelAdmin is an extension of the Wagtail ModelAdmin that allows for model instances to be copied in the user interface with a "Copy" button.

Dependencies

  • Python 3.6+
  • Django 1.11+, 2.0+
  • Wagtail 1.13+, 2.0+

Installation

  1. Install wagtail-copyablemodeladmin:
pip install wagtail-copyablemodeladmin
  1. Add copyablemodeladmin as an installed app in your Django settings.py:
INSTALLED_APPS = (
    ...
    'copyablemodeladmin',
    ...
)

Usage

Please see the Wagtail ModelAdmin documentation for getting started with ModelAdmin.

When creating a ModelAdmin for objects that should be copyable, instead of inheriting from ModelAdmin, inherit from copyablemodeladmin.options.CopyableModelAdmin:

from wagtail.contrib.modeladmin.options import modeladmin_register
from copyablemodeladmin.options import CopyableModelAdmin
from myapp.models import Book


# Inherit from CopyableModelAdmin instead of ModelAdmin
class BookAdmin(CopyableModelAdmin):
    model = Book
    list_display = ('title', 'author')
    list_filter = ('author',)
    search_fields = ('title', 'author')

# Now you just need to register your customised ModelAdmin class with Wagtail
modeladmin_register(BookAdmin)

In addition to CopyableModelAdmin, there are three mixin classes that can be added to other custom ModelAdmin subclasses:

from copyablemodeladmin.helpers import CopyButtonHelperMixin
from copyablemodeladmin.options import CopyableModelAdminMixin
from copyablemodeladmin.views import CopyViewMixin


class CustomCopyButtonHelper(CopyButtonHelperMixin, CustomButtonHelper):
    pass


class CustomCopyInstanceView(CopyViewMixin, CustomInstanceSpecificView):
    pass


class CustomCopyableModelAdmin(CopyableModelAdminMixin, ModelAdmin):
    button_helper_class = CustomCopyButtonHelper
    copy_view_class = CustomCopyInstanceView

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

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for wagtail-copyablemodeladmin, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size wagtail_copyablemodeladmin-1.0.0-py3-none-any.whl (10.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size wagtail-copyablemodeladmin-1.0.0.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page