Skip to main content

Easily add CMS functionality to your Django site

Project description

django-freeplay

Freeplay is a new approach for easily adding CMS functionality to your Django app. Define regions for managing (and allowing clients to manage) bits of content on your site that don’t need the full build-out of custom apps. For example, that list of links in the footer, or the photo and bio of the CEO. With Freeplay, each region can contain one or many items, so you quickly gain flexible model-like functionality.

Each bit of content gets rendered onsave with Django’s template processor, so you have all the power of the Django’s parser.

Installation

  1. pip install django-freeplay

  2. Add 'freeplay' to your INSTALLED_APPS in your project’s settings.py

  3. (Optional) Add (r"^admin/freeplay/", include("freeplay.urls_admin")), to your main urls.py, before you include the admin urls

  4. Sync your db or use your migration tool of choice (recommended: nashvegas)

Requirements

Installing freeplay will also bring django-model-utils, django-imagekit, and django-relatedadminwidget with it.

The admin templates assume the existence of a few CSS and JS libraries: Chosen, Isotope, and jQuery.Slugify. Simply override the templates with ones in your project to define your own paths or libs.

Usage

In the django admin, create a new freeplay Template. Start by defining the template bits and then write the template code. For example, let’s say we want to manage a few FAQs. We’d create one bit like so:

Kind: Plain Text
Name: Question
Context name: question
Order: 1
Text Widget: Textarea Input Field
Required: True

And another:

Kind: Markdown
Name: Answer
Context name: answer
Order: 2
Text Widget: Textarea Input Field
Required: True

(Note: if you use Markdown, be sure you’ve added markdown to your requirements)

When you set up the bits for a template, you’re defining the form that you or your clients will use to add and edit content for items that use this template. As such, you can include help text with each bit.

Now we can write the following for the template Code:

<span class="number">{{ order }}</span>
{{ question|title }}
<div class="answer">{{ answer|safe }}</div>

Note we need to use the safe filter for HTML content, and also that each item will include its “order” in context as well as “label”.

As soon as you have a template, create a Region and then you can start adding content, which is easily done using the included admin urls and templates.

Templatetags

Here’s how you fetch and display freeplay content in your templates:

{% load freeplay_tags %}

content_bits : assignment tag, accepts “region_slug” as argument

{% content_bits "question-answer" as qa_items %}
{% for item in qa_items %}
<li>{{ item.data|safe }}</li>
{% endfor %}

get_bit : assignment tag, requires “region_slug” and “item_slug” as args

{% get_bit "site_constants" "footer-company-summary" as co_summary %}
<footer>
    <h1>About the Company</h1>
    <p>{{ co_summary.data }}</p>
</footer>

Also

Freeplay regions let you set “Min Items” and “Max Items”, optionally. On the freeplay admin dashboard, it will then alert you if a region needs more content to meet the minimum requirement and won’t show the “Add” link if the region has met the maximum limit.

Hope you find this useful!

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-freeplay-0.1.5.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-freeplay-0.1.5.tar.gz.

File metadata

File hashes

Hashes for django-freeplay-0.1.5.tar.gz
Algorithm Hash digest
SHA256 8df958c1d517636676a244d3c9be554960bcc24cb2a6c6201ecc9c4d81f2e84b
MD5 a84634a6d8343c04aa06fa1399749f4a
BLAKE2b-256 8128fb5b290d737e0844ec78173aad7dff40c8a847894d963cc3cbe2b0bc9acb

See more details on using hashes here.

Provenance

File details

Details for the file django-freeplay-0.1.5.macosx-10.8-x86_64.tar.gz.

File metadata

File hashes

Hashes for django-freeplay-0.1.5.macosx-10.8-x86_64.tar.gz
Algorithm Hash digest
SHA256 950843023bf50a8a71130647f07bf69e6238739cf8ecc715314688f70d228b14
MD5 76c009186475128ba02a9034d848fbe1
BLAKE2b-256 1da3c323e33f00a7e82ec948bfe49072973bcf17123acdae9630cb4b874c4f9a

See more details on using hashes here.

Provenance

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