Skip to main content

This reusable Django app lets you store snippets of text (“grains”) in the database keyed by arbitrary strings. It’s the same idea implemented previously in django-chunks, django-flatblocks, django-tinycontent and others.

Usage

Install with pip install django-grains.

Add grains to INSTALLED_APPS in your project’s Django settings.

Run manage.py syncdb or manage.py migrate (if you’re using South) to create the database tables.

In your templates, create placeholders for grains:

{% load grains_tags %}

{% grain "front-page-title" %}The default title of the front page{% endgrain %}

{% grain "front-page-subtitle" "text/plain" %}The default subtitle of the front page{% endgrain %}

{% grain "front-page-content" "text/html" %}
    <p>This is the default HTML content of the front page.</p>
{% endgrain %}

The first argument to {% grain %} is the unique identifier of the grain. The second argument is the content type which could be used to choose the editor widget for the value in Django’s admin interface. The second argument can be omitted in which case it defaults to text/plain.

A WYSIWYG editor is automatically used in the admin interface for grains with the text/html content type, if you have django-wysiwyg installed and added to INSTALLED_APPS.

Release files for django-grains 0.2.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 django-grains 0.2.2
File Size Uploaded
django-grains-0.2.2.tar.gz 3.5 kB Details

Release files / django-grains-0.2.2.tar.gz

Download URL django-grains-0.2.2.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f51d46060b8219529c3772917f5b0ef4e84d27dde735d4a9d922df4ac5535bfb
BLAKE2b-256 checksum
How to use checksums
9b745b1c3e740c97d0a4a8aa63f9850b661c3c8485286fc606f517aeea44a827
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

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