Translatable flatpages
Project description
Translatable version of django.contrib.flatpages with basic menu support.
Requirements
Django
django_modeltranslation
django_mptt
Tested with Django 1.8.
Installation
Install python library using pip: pip install django-flatpages-i18n
Add mptt, modeltranslation and flatpages_i18n to INSTALLED_APPS in your Django settings file
Add flatpages_i18n.middleware.FlatpageFallbackMiddleware to MIDDLEWARE_CLASSES in your Django settings file
Specify desired languages in your Django settings file:
from django.utils.translation import gettext LANGUAGE_CODE = 'en' LANGUAGES = ( ('en', gettext('English')), ('de', gettext('German')), )
Migrate your database
Run sync_translation_fields and update_translation_fields commands (from modeltranslation app)
If you want to use Redactor WYSIWYG editor (see settings below), you need to add 'flatpages_i18n.urls' to your urls.py:
if 'flatpages_i18n' in settings.INSTALLED_APPS: urlpatterns += i18n_patterns( url(r'^', include('flatpages_i18n.urls')), )
Usage
To get all flatpages:
In your HTML template:
{% load i18n flatpages_i18n %} {% get_available_languages as LANGUAGES %} {% get_flatpages_i18n as flatpages_i18n %} <ul> {% for flatpage in flatpages_i18n %} <li><a href="/{{ LANGUAGE_CODE }}{{ flatpage.url }}">{{ flatpage.title }}</a></li> {% endfor %} </ul>
To get flatpage by its PK:
{% get_flatpage_i18n 123 as my_flatpage %} {{ my_flatpage.content }}
or by its machine_name:
{% get_flatpage_i18n 'my-flatpage' as my_flatpage %}
Settings
- FLATPAGES_EDITOR
If you wish to use Redactor as WYSIWYG editor, set it to 'REDACTOR'. Default: None.
- FLATPAGES_REDACTOR_JS
Path to Redactor .js file. Default: 'js/redactor/redactor.js'.
- FLATPAGES_REDACTOR_CSS
Path to Redactor .css file. Default: 'css/redactor/redactor.css'.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-flatpages-multilanguage-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52fd7c5e24c73357fe039f0bb71c40b674b74c3d87af331f23ad643175e5cfdd |
|
MD5 | 666efdb8373027db905ab1503b8ea329 |
|
BLAKE2b-256 | 48dc884771158ca2e0f5e4f2c771ef183ff07446060e38035906b3cfe7e2a870 |
Hashes for django_flatpages_multilanguage-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2544ce1820590708b79b11de379fc72e9a67dca2c7ce548539c02b015bf02c6e |
|
MD5 | edc65314df9e13c9ee16b7f23dda9f00 |
|
BLAKE2b-256 | fb3be12fc2345de2a5f8a6ccedbc8caa97cbdf72ffa82a015707e6043dcd5e36 |