djangocms2000 is a flexible Django CMS with edit-in-place capability.
- Django, version 1.4 or higher
- sorl.thumbnail version 10+, or easy_thumbnails version 2.3+ (optional, required for automatically resizing cms images)
- importlib, for python < 2.7
-
Run
./setup.py install
to install the cms. Alternately, you can symlink or move thecms
directory onto your path. -
Add
'cms'
toINSTALLED_APPS
-
Add
'cms.urls'
to yourROOT_URLCONF
conf, i.e.(r'^cms/', include('cms.urls')),
-
Ensure
'django.core.context_processors.request'
is present in yourTEMPLATE_CONTEXT_PROCESSORS
setting -
Ensure
'django.template.loaders.app_directories.load_template_source'
is present in yourTEMPLATE_LOADERS
setting -
Optional: Install sorl.thumbnail or easy_thumbnails as per the relevant documentation if you want to use resized cms images
-
Optional: add
'cms.middleware.CMSFallbackMiddleware'
to your middleware classes if you want to be able to add new pages via Django's admin. -
Optional: add
{% cms_editor %}
to the bottom of your base template to enable sitewide in-place editing (use{% load cms_editor %}
to load)
- Use
{% load cms_tags %}
to enable the cms tags in a template/ - Use
{% cmsblock LABEL [format=FORMAT] %}
to create an editable text block. FORMAT can be 'plain' (default) or 'html'. - Use
{% cmsimage LABEL [geometry=GEOMETRY crop=CROP] %}
to create editable images. GEOMETRY and CROP (both optional) correspond to the sorl.thumbnail's geometry and crop options, or easy_thumbnails size and crop options. If not specified, the original image will be displayed.
Add the functions in cms.jinja2_env
to your jinja2 environment. For example:
from jinja2 import Environment
import cms.jinja2_env
env = Environment()
env.globals.update(cms.jinja2_env.template_globals)
Basic usage examples:
{{ cms_block('intro', filters='linebreaks') }}
{{ cms_block('content', format='html') }}
{{ cms_block('site-intro', site=True) }}
{{ cms_image('resized-image', '200x200') }}
{{ cms_image('cropped-image', '200x200', crop=True) }}
{{ cms_image('raw-image') }}
Custom image rendering can be achieved via the renderer argument, which can be defined as a jinja2 macro - i.e.
{% macro image_as_bg(img) %}
<div class="image" style="background-image: url({{ img.url }})"></div>
{% endmacro %}
{{ cms_image('bg-image', '200x200', renderer=image_as_bg) }}
-
First make sure you are running the latest 1.x series tag (see here). Refer to notes.markdown for pre-1.0 migration instructions.
-
If you're using South, you may need to fake the first migration, ie.
./manage.py migrate cms 0001_initial --fake
(If not using South, you'll need to modify your db to match the new schema by hand.)
-
The
{% cmsextra %}
tag becomes{% cms_editor %}
, and now requires a separate import,{% load cms_editor %}
. -
The
'markdown'
block format has been removed, and the default is now'plain'
.format
is also now a keyword argument, e.g.{% cmsblock 'text' format='html' %}
. -
The
format
argument has been removed from{% cmsimage ... %}
and its variants, since the new extended syntax renders it obsolete.
CMS database content can be kept separate from the rest of the database. To
enable, set CMS_DB_ALIAS
to point to a secondary database and add
'cms.db_router.CMSRouter'
to your DATABASE_ROUTERS
setting. For example,
you may want to store CMS content in an sqlite database which can be easily
committed to version control. CMS media, by default, is stored in the cms
subfolder of MEDIA_ROOT
.
See reference.markdown for more info