Skip to main content

'Copy A Snippet' Feature for Wagtail CMS

Project description

# 'Copy A Snippet' Feature for Wagtail CMS

You can now "copy" snippets (non-page models) in Wagtail CMS


## Installation

1. Install the python package wagtailsnippetscopy from pip

``pip install wagtailsnippetscopy``

Alternatively, you can install download or clone this repo and call ``pip install -e .``.

2. Add to INSTALLED_APPS in your **settings.py**:

`'wagtailsnippetscopy',`

3. Register a model (with a title field name) you wish to enable copy functionality for:

```
from wagtailsnippetscopy.registry import snippet_copy_registry

snippet_copy_registry.register(YourModel, 'title_field_name')

```

4. Add SnippetCopyMixin to your Snippet model in order to enable get_copy_url callback() for the model:

```
from wagtailsnippetscopy.models import SnippetCopyMixin

@register_snippet
class Graph(SnippetCopyMixin, models.Model):
```

5. If you wish copy link to automatically appear in modeladmin list you should add SnippetCopyModelAdminMixin to the ModelAdmin class:

In admin.py:

```python
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from wagtailsnippetscopy.admin import SnippetCopyModelAdminMixin
from .models import YourModel

class YourModelAdmin(SnippetCopyModelAdminMixin, ModelAdmin):
model = YourModel

modeladmin_register(GraphAdmin)
```

6. Copy link follows the following pattern:

```
/admin/snippets/<app_label>/<model_name>/<object_id>/copy/
```

## Bugs and suggestions

If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.

[https://github.com/timonweb/wagtailsnippetscopy/issues](https://github.com/timonweb/wagtailsnippetscopy/issues)

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

wagtailsnippetscopy-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file wagtailsnippetscopy-0.1.0.tar.gz.

File metadata

File hashes

Hashes for wagtailsnippetscopy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 33c7c78be03a4cbbf131fd98d44dc4b24a1f2d2b2473406126bc7752014fdfbf
MD5 97315a00edd4dec3491ca340ca3c8adf
BLAKE2b-256 10dbb2ee628b00f614ab7e6fda9eaaeefcd7fccdfe47a403e973e80b18b6792c

See more details on using hashes here.

Supported by

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