Translatable flatpages
Project description
Translatable version of django.contrib.flatpages with menu support.
Requirements
Django
django_modeltrans
django_mptt
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
File details
Details for the file django-flatpages-i18n-1.0.0.tar.gz
.
File metadata
- Download URL: django-flatpages-i18n-1.0.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc047a9fdc52e9e05652287913795eeeca71b357afdc15be37f235bea6b3cd57 |
|
MD5 | 27ee8ae40d731989868ca2d08ebe0150 |
|
BLAKE2b-256 | 969ce0c9d4160877eaa1323e6f366b46c7606d10f9aaee9acce911c9b449d986 |