This is a simple Django app that adds functionality to django-model-gatekeeper
.
It creates two models:
CuratedContentBlock
CuratedContentInstance
Basically you create 1 or more instances that are assigned to blocks. You reference blocks in templates, and the "correct" instance will appear depending on it's Gatekeeper publish_status
and live_as_of
date.
-
pip install django-curated-content
-
You must have "gatekeeper" and "curated_content" in your INSTALLED_APPS.
INSTALLED_APPS = [ ... 'gatekeeper', 'curated_content', ]
-
python manage.py migrate
to create the models.
The main use for gatekeeping is where you have a model with many instances, but you only want some to be "live" on the site.
Please refer to the django-model-gatekeeper
documentation on how gatekeeping works.
These define a block of content that you'll want to appear within one or more templates, but that you want to update automatically on the site per a pre-arranged schedule.
For example if your site has a promotion, you might want content that announces it prior to the start ("New Feature Coming Soon!"), that changes when the promotion starts ("Check out our New Feature"), and again one or more times during the promotion ("Get 20% off! Promotion Ending Soon"), and disappears after the promotion.
By creating a content block, you can make content instance for each of these circumstances, set a live_as_of
date, and the content will cycle through as directed.
For each content block, no more than one instance will ever be live at any time. (It is entirely possible, and sometimes desired/necessary to have NO instances live.)
You can see which instance is "live" on the Curated Content Instances admin listing page.
Rendering Curated Content is done through a template tag, curated_content
.
-
First add {% load curated_content %} at the top of the template.
-
Set the context to include the curated content: here the content block is
my-content-blog-slug
:{% curated_content 'my-content-blog-slug' as promo_banner %}
-
Use the updated context where desired:
{{ promo_banner }}
.
TBD.
TBD.
-
Admin Preview
-
Markdown, HTML, etc.