Skip to main content

pypi coverage python django djangocms djangocms4

django CMS Snippet provides a plugin for django CMS to inject HTML, CSS or JavaScript snippets into your website.

This project is endorsed by the django CMS Association. Join us on Slack.

Warning: We recommend using this plugin only during development:

This plugin is a potential security hazard, since it allows authorized-
users to place custom markup or Javascript on pages bypassing all of
Django's normal sanitization mechanisms. This could be exploited by users
with the right to add snippets to elevate their privileges to superusers.
This plugin should only be used during the initial development phase for
rapid prototyping and testing.
preview.gif

Contribute to this project and win rewards

Because this is a an open-source project, we welcome everyone to get involved in the project and receive a reward for their contribution. Become part of a fantastic community and help us make django CMS the best CMS in the world.

We’ll be delighted to receive your feedback in the form of issues and pull requests. Before submitting your pull request, please review our contribution guidelines.

We’re grateful to all contributors who have helped create and maintain this package. Contributors are listed at the contributors section.

One of the easiest contributions you can make is helping to translate this addon on Transifex.

Documentation

See REQUIREMENTS in the setup.py file for additional dependencies.

Installation

For a manual install:

  • run pip install djangocms-snippet

  • add djangocms_snippet to your INSTALLED_APPS

  • run python manage.py migrate djangocms_snippet

Djangocms-snippet uses the ace code editor which normally is loaded from a CDN. If you prefer your application to provide the editor locally, you can change the requirement from djangocms_snippet to djangocms_snippet[static-ace] and add djangocms_static_ace to your project’s INSTALLED_APPS.

Configuration

To allow the contents of all snippets to be searchable, please set DJANGOCMS_SNIPPET_SEARCH to True in your settings:

DJANGOCMS_SNIPPET_SEARCH = True

We are using Ace as our editor of choice to edit the snippet content. You can customize the theme and mode through:

DJANGOCMS_SNIPPET_THEME = 'github'
DJANGOCMS_SNIPPET_MODE = 'html'

If dynamic content is inserted (for example {% show_menu ... %}), the plugin cache must be disabled, please set DJANGOCMS_SNIPPET_CACHE to False in your settings:

DJANGOCMS_SNIPPET_CACHE = False # default value is False

django CMS 4 and later

If you use djangocms-versioning or djangocms-moderation, you can have snippets versioned and moderated by adding the following to your settings:

DJANGOCMS_SNIPPET_VERSIONING = True  # Set to version with djangocms-versioning
DJANGOCMS_SNIPPET_MODERATION = True  # Set to moderate with djangocms-moderation

If you enable versioning (e.g., set DJANGOCMS_SNIPPET_VERSIONING = True) for djangocms-snippets in a project that already contains snippets, you will need to create Version objects for those existing snippets using the create_version management command provided by djangocms-versioning.

Template tag

You can also use a template tag to render a snippet rather than a plugin:

{% load snippet_tags %}
{% snippet_fragment [reference] %}

Replace [reference] with either:

  • The snippet ID, e.g. {% snippet_fragment 42 %}

  • The snippet slug, e.g. {% snippet_fragment 'my-snippet' %}

  • The snippet instance, e.g. {% snippet_fragment instance.snippet %}

Optionally provide a fallback if there is no matching id/slug/instance:

{% snippet_fragment 'my-snippet' or %}
    ... your content fallback here ...
{% endsnippet_fragment %}

Known Issues

When adding a snippet with the object or embed tag as root element, the CMS toolbar crashes, making any further editing of the page difficult or impossible. A workaround is to just put those elements inside a div tag.

Running Tests

You can run tests by executing:

virtualenv env
source env/bin/activate
pip install -r tests/requirements.txt
python setup.py test

Release files for djangocms-snippet 5.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangocms-snippet 5.0.2
File Size Uploaded
djangocms_snippet-5.0.2.tar.gz 44.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangocms-snippet 5.0.2
File Interpreter ABI Platform
djangocms_snippet-5.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 200.7 kB

Release files / djangocms_snippet-5.0.2.tar.gz

Download URL djangocms_snippet-5.0.2.tar.gz
Size 44.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d3b19abc62b8f665e104b7aa5489292b397e46d61fc4f3ee27b7f122d8b8bb65
BLAKE2b-256 checksum
How to use checksums
42519c7f181024280920d5c1a347ad69c22c788fa9508b123992dbacacd64bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2025.

Transparency log

Release files / djangocms_snippet-5.0.2-py3-none-any.whl

Download URL djangocms_snippet-5.0.2-py3-none-any.whl
Size 156.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42fdf0a37a80175184197315fc20475a1e019b72d01cc1621c04f3cb7d0f797c
BLAKE2b-256 checksum
How to use checksums
0092cf1c4714cec92683a0c7564ee268311faa4a8bb0a722af269e26998bcd92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 3, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

5.0.2 This release

2 release files

5.0.1

2 release files

5.0.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.3.0

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.0

2 release files

1.9.2

1 release file

1.9.1

1 release file

1.9.0

1 release file

1.8.2

2 release files

1.8.1

1 release file

1.8.0

1 release file

1.7.1

2 release files

1.7.0

2 release files

1.5

1 release file

1.4

2 release files

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page