Skip to main content

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

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

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

  3. Migrate your database

  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. 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 %}

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_i18n-2.0.0.tar.gz (9.8 kB view details)

Uploaded Source

File details

Details for the file django_flatpages_i18n-2.0.0.tar.gz.

File metadata

  • Download URL: django_flatpages_i18n-2.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for django_flatpages_i18n-2.0.0.tar.gz
Algorithm Hash digest
SHA256 65b011a410faf8fcda2b1facc69ac5a01dcfafb14062c97fcece7c146c23cb75
MD5 f5403e680f9bcd2d0ac0a20e1a47a899
BLAKE2b-256 2d761a48ece0c02ab26e2ceaddfb8a1f0b672b4573a4041ba0559a862a4983c5

See more details on using hashes here.

Supported by

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