Getting Started

Below are the basic steps need to get django-scribbler integrated into your Django project.

Configure Settings

You need to include scribbler to your installed apps. django-scribbler requires django.contrib.auth which in turn requires django.contrib.sessions which are enabled in Django by default. You will also need to include a context processor to include the current request in the template context.

    # Required contrib apps
    # Other installed apps would go here

    # Other context processors would go here

Note that TEMPLATE_CONTEXT_PROCESSORS is not included in the default settings created by startproject. You should take care to ensure that the default context processors are included in this list. For a list of default TEMPLATE_CONTEXT_PROCESSORS please see the official Django docs.

For the context processor to have any effect you need to make sure that the template is rendered using a RequestContext. This is done for you with the render shortcut.

django-scribbler aggressively caches the scribble content. By default the scribble content is cached for 12 hours. You have the option to configure this cache timeout with the SCRIBBLER_CACHE_TIMEOUT setting. The value should be the timeout in seconds.

Configure Urls

You should include the scribbler urls in your root url patterns.

urlpatterns = patterns('',
    # Other url patterns would go here
    url(r'^scribbler/', include('scribbler.urls')),

Create Database Tables

You’ll need to create the necessary database tables for storing scribble content. This is done with the syncdb management command built into Django:

python syncdb

django-scribbler uses South to handle database migrations. If you are also using South then you should run migrate instead:

python migrate scribbler

User Permissions

To edit scribbles on the front-end users must have the scribbler.add_scribble and scribbler.change_scribble permissions. You can configure uses to have these permissions through the users section of the Django admin. Superusers have all of these permissions by default.

Include Static Resources

django-scribbler includes both CSS and JS resources which need to be included in your templates to handle the front-end content management. Since you may want to include scribbles on any page on your site these should be included in your base template <head>.

<link rel="stylesheet" href="{{ STATIC_URL }}scribbler/libs/codemirror.css">
<link rel="stylesheet" href="{{ STATIC_URL }}scribbler/css/scribbler.css">
<script data-main="{{ STATIC_URL }}scribbler/js/scribbler" src="{{ STATIC_URL }}scribbler/libs/require.js"></script>

This uses RequireJS to load the additional JS resources. The front-end editor uses CodeMirror (currently using v2.32) which is included in the distribution. Both RequireJS and CodeMirror are available a MIT-style license compatible with this project’s BSD license. You can find the license files included in scribbler/static/scribbler/libs/.

Place Scribbles in Your Template

You are now ready to place the scribble content blocks throughout your templates. This is done with the scribble block tag. It takes one argument which is the slug name for the scribble. Slugs must be unique per url/slug pair. That means you cannot use the same slug more than once in the template but you can use the same slug in different templates as long as they are rendered on different urls.

{% load scribbler_tags %}
{% scribble 'header' %}
    <p>Blip {% now 'Y' %} {{ STATIC_URL|upper }}</p>
{% endscribble %}

The content inside the block is the default content that will be rendered if a matching scribble in the database is not found.


Scribble content can be any valid Django template. However the content does not include all of the context of the template. Only the context provided by the set of TEMPLATE_CONTEXT_PROCESSORS.

That should be enough to get you up and running with django-scribbler.

Project Versions

Table Of Contents

Previous topic


Next topic

Release History

This Page