Options, Labels and standalone Texts for django admin. Administrator emails, phones, contact data, etc.
qOptions package allows you to create records in database, wich you can use in your templates and views.
If you need multisite template tags suppers, define in settings.py OPTIONS_MULTISITE:
# Options
OPTIONS_MULTISITE = True
Works with django-modeltranslation and django-tinymce
Add 'modeltranslation' to INSTALLED_APPS and 'options.translation' to MODELTRANSLATION_TRANSLATION_FILES
Add 'tinymce' to INSTALLED_APPS
In python code you can use:
from options.functions import get_option, get_label, get_text
print get_option('your_option_key') # 'value'
print get_label('your_label_key') # 'value'
print get_text('your_text_key') # ['title', 'text']
In templates:
{% load options %}
{% get_option 'your_option_key' %}
{% get_label 'your_label_key' %}
Or if you want return to context variable:
{% get_option 'your_option_key' 'my_option_key' %}
{{ my_option_key }}
{% get_label 'your_label_key' 'my_label_key' %}
{{ my_label_key }}
With texts it's a little more complicated. You need two texts, but you probably do not wont hit database or cache twice. So we return first variable directly and second as context variable.
{% get_text 'your_text_key' 'my_title' %}
{{ my_title }}
OR (if you need title first)
{% get_text_title 'your_text_key' 'my_text' %}
{{ my_text }}
Ofcourse we can return both variables as context variables:
{% get_text 'your_text_key' 'my_title' 'my_text' %}
OR
{% get_text_title 'your_text_key' 'my_text' 'my_title' %}
AND
{{ my_title }}: {{ my_text }}
Title and text:
<h1>{% get_editable_text_title 'your_text_key' as_var='my_text' %}</h1>
<div>{{ my_text }}</div>
Labels:
<span>{% get_editable_label 'your_text_key' %}</span>
Name space - KEY_NAME_ID (where ID is your SITE_ID)
Available multisite template tags: get_option_multisite
, get_label_multisite
, get_text_multisite
, get_text_title_multisite
, get_editable_option_multisite
, get_editable_label_multisite
, get_editable_text_multisite
, get_editable_text_title_multisite