Skip to main content

Efficient django template blocks implementation

Project description

Installation
============

1. Add ``cmstemplates`` to ``INSTALLED_APPS``
2. Append ``cmstemplates.loaders.Loader`` to
the end of ``TEMPLATE_LOADERS`` setting
3. Configure your file-based templates directory::

ZONE_TEMPLATES_DIR = os.path.join(BASE_DIR, 'zone_templates')

4. Create directory ``zone_templates`` near ``settings.py`` file
5. Run ``./manage.py migrate cmstemplates``
6. Go to admin and create new zone template with name *test-zone*
7. Add this zone to your template with built-in django ``include`` tag::

{% include "test-zone" %}

Using codemirror widget
=======================

Add to your settings::

ZONE_TEMPLATE_USE_CODEMIRROR = True

Install codemirror widget::

1. source env/bin/activate
2. pip install django-codemirror-widget
3. cd project_name/static/vendor
4. wget http://codemirror.net/codemirror.zip
5. unzip codemirror.zip
6. mv codemirror-4.2 codemirror
7. Add to settings::

CODEMIRROR_PATH = 'vendor/codemirror'
CODEMIRROR_THEME = 'default'
CODEMIRROR_CONFIG = {'lineNumbers': True}


Final settings should look like this::

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
'cmstemplates.loaders.Loader',
)

# cmstemplates
ZONE_TEMPLATES_DIR = os.path.join(BASE_DIR, 'zone_templates')
ZONE_TEMPLATE_USE_CODEMIRROR = True

# codemirror
CODEMIRROR_PATH = 'vendor/codemirror'
CODEMIRROR_THEME = 'default'
CODEMIRROR_CONFIG = {'lineNumbers': True}

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-cmstemplates-0.2.tar.gz (9.2 kB view details)

Uploaded Source

File details

Details for the file django-cmstemplates-0.2.tar.gz.

File metadata

File hashes

Hashes for django-cmstemplates-0.2.tar.gz
Algorithm Hash digest
SHA256 86e07cb9447c292a6517cb1fa17194fd8b12b702a040a18a9e84c34f44eab33b
MD5 149cb0cf8a54545c2c2cf59b1b21299c
BLAKE2b-256 ae5522ebac1e977e5c61ae985ec273d7533e5530f5bfc2b537d09883a271f724

See more details on using hashes here.

Supported by

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