Skip to main content

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

Menu system:

To print all menu items:

<div id="navigation">
    {% menu_i18n %}
</div>

to get only children of menu item identified by its PK:

<div id="navigation">
    {% menu_i18n 2 %}
</div>

or by its machine_name:

<div id="navigation">
    {% menu_i18n 'footer-menu' %}
</div>

You can also assign menu items into variable:

{% get_menu_i18n 'my-menu' as my_menu %}
{% for item in my_menu %}
    <a href="{{ item.get_absolute_url }}" target="{{ item.target }}">{{ item }}</a>
{% endfor %}

Authors

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

Metadata

Release files for django-flatpages-i18n 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-flatpages-i18n 2.0.2
File Size Uploaded Provenance
django_flatpages_i18n-2.0.2.tar.gz 10.3 kB Without provenance Details

Release files / django_flatpages_i18n-2.0.2.tar.gz

Download URL django_flatpages_i18n-2.0.2.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ebdaa078d103ddd0d9979664a5660d4dd1105185fc864da23c6e6649d3468b4d
BLAKE2b-256 checksum
How to use checksums
8a908b69b6838eecb232e161c5d15c0151327bebea9b9c372bfdeddd8ae17b3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for django-flatpages-i18n 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page