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


Download files

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

Source Distribution

wagtail-copyablemodeladmin-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

wagtail_copyablemodeladmin-1.0.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file wagtail-copyablemodeladmin-1.0.0.tar.gz.

File metadata

  • Download URL: wagtail-copyablemodeladmin-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9

File hashes

Hashes for wagtail-copyablemodeladmin-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4c98d235699ed08aefa1f6c23cecdc513c33c15277e115543531e09d5450a9d3
MD5 263a2c02b983377c78e52c653d19c5b2
BLAKE2b-256 dbec9946219cda51415ed54b47d63885248127665b43deccd3b7c43007f19d7a

See more details on using hashes here.

Provenance

File details

Details for the file wagtail_copyablemodeladmin-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: wagtail_copyablemodeladmin-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9

File hashes

Hashes for wagtail_copyablemodeladmin-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afdc43e02bfd54b60655352e7d38f86ade9273fa30b939519eaffb4bcda8296e
MD5 91185edf823980c1bebceb0fc0bce66f
BLAKE2b-256 272fedf586ee150746d40ee0cd9b7eea74cf8903acf3c472bd15bcb61c803e27

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page