Skip to main content

Parametrizable Django CMS snippets.

Project description


smartsnippets is a django-cms plugin similar to the builtin snippet plugin but instead of allowing only plain HTML you can use any valid Django template syntax inside. When a smartsnippet is added in a page the user can provide values for all detected used variables. This is much more flexible than the standard snippet if you want to parametrize and reuse your static snippets.


All variables enclosed in curly-braces are automatically detected. In some cases you may need to artificially create such a construct for a variable to be detected. If a variable name ends with _ it won’t be detected.


A simple smartsnippet using the Twitter profile example:

<script src=""></script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 4,
  interval: 30000,
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#333333',
      color: '#ffffff'
    tweets: {
      background: '#000000',
      color: '#ffffff',
      links: '#4aed05'
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    behavior: 'all'

Note the {{twitter_username}} variable used as a standard Django variable. When adding the smartsnippet in a page, the form will provide an input field where you can set a value of that variable.


There are three configuration variables available:

  • SMARTSNIPPETS_SHARED_SITES a list of site names defaulting to an empty list. All the sites listed here will share their smartsnippets with all the other sites as read-only. This can be Useful in a shared environment to enable code sharing.
  • SMARTSNIPPETS_INCLUDE_ORPHAN a boolean flag that defaults to True. If this option is enabled, selecting a site in the smartsnippet creation form is optional. If a smartsnippet doesn’t belong to any site it will behave as global and will be available in all sites. If set to False the user will be forced to link the smartsnipptes that he creates to at least one site.
  • SMARTSNIPPETS_RESTRICT_USER a boolean flag that defaults to False. This flag, if set, will limit the smartsnippets that a user can access based on his relation to sites trough the global pages permission system. This can be useful in a shared environment. By default a user can access all the smartsnippets in the system.


This plugin is a potential security hazard, since it allows admins to place custom JavaScript on pages. This may allow administrators 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 should be disabled on production sites.

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

django-cms-smartsnippets-0.1.3.tar.gz (12.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page