Skip to main content

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

  1. Install python library using pip: pip install django-flatpages-i18n

  2. Add mptt, modeltranslation and flatpages_i18n to INSTALLED_APPS in your Django settings file

  3. Add flatpages_i18n.middleware.FlatpageFallbackMiddleware to MIDDLEWARE_CLASSES in your Django settings file

  4. Specify desired languages in your Django settings file:

    from django.utils.translation import gettext
    
    LANGUAGE_CODE = 'en'
    LANGUAGES = (
        ('en', gettext('English')),
        ('de', gettext('German')),
    )
  5. Migrate your database

  6. Run sync_translation_fields and update_translation_fields commands (from modeltranslation app)

  7. 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'.

Authors

Library is by Erik Telepovsky from Pragmatic Mates. See our other libraries.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-flatpages-multilanguage-0.1.0.tar.gz (102.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_flatpages_multilanguage-0.1.0-py3-none-any.whl (106.1 kB view details)

Uploaded Python 3

File details

Details for the file django-flatpages-multilanguage-0.1.0.tar.gz.

File metadata

  • Download URL: django-flatpages-multilanguage-0.1.0.tar.gz
  • Upload date:
  • Size: 102.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for django-flatpages-multilanguage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 52fd7c5e24c73357fe039f0bb71c40b674b74c3d87af331f23ad643175e5cfdd
MD5 666efdb8373027db905ab1503b8ea329
BLAKE2b-256 48dc884771158ca2e0f5e4f2c771ef183ff07446060e38035906b3cfe7e2a870

See more details on using hashes here.

File details

Details for the file django_flatpages_multilanguage-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_flatpages_multilanguage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 106.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8

File hashes

Hashes for django_flatpages_multilanguage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2544ce1820590708b79b11de379fc72e9a67dca2c7ce548539c02b015bf02c6e
MD5 edc65314df9e13c9ee16b7f23dda9f00
BLAKE2b-256 fb3be12fc2345de2a5f8a6ccedbc8caa97cbdf72ffa82a015707e6043dcd5e36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page