Translatable flatpages
Project description
Translatable version of django.contrib.flatpages with menu support.
Requirements
Django
django_modeltrans
django_mptt
django-pragmatic
Tested with Django 1.8.
Installation
Install python library using pip: pip install django-flatpages-i18n
Add mptt, modeltrans and flatpages_i18n to INSTALLED_APPS in your Django settings file
Migrate your database
Specify desired languages in your Django settings file:
from django.utils.translation import gettext LANGUAGE_CODE = 'en' LANGUAGES = ( ('en', gettext('English')), ('de', gettext('German')), )
Addd 'flatpages_i18n.urls' to your urls.py:
if 'flatpages_i18n' in settings.INSTALLED_APPS: urlpatterns += i18n_patterns( path(pgettext_lazy('url', 'pages/'), include('flatpages_i18n.urls')), )
Usage
To get all flatpages:
In your HTML template:
{% load i18n flatpages_i18n %} {% get_flatpages_i18n as flatpages_i18n %} <ul> {% for flatpage in flatpages_i18n %} <li><a href="{{ flatpage.get_absolute_url }}">{{ flatpage }}</a></li> {% endfor %} </ul>
To get flatpage by its PK:
{% get_flatpage_i18n 123 as my_flatpage %} {{ my_flatpage.content_i18n }}
or by its machine_name:
{% get_flatpage_i18n 'my-flatpage' as my_flatpage %}
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
Close
Hashes for django-flatpages-i18n-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1489343cc3815e8c25853760f21c13e5d791c0c48fd8f1fe81d315702ca41ef |
|
MD5 | eab61fcfb1d7db42cb5cf9b86f61b01a |
|
BLAKE2b-256 | c9b211bf98e1bc4b318c3128dda0f9a21a88620dabe07860d265724940ff364f |