Skip to main content

django-multilingual-flatpages

https://secure.travis-ci.org/codesyntax/django-multilingual-flatpages.png?branch=master https://coveralls.io/repos/github/codesyntax/django-multilingual-flatpages/badge.svg?branch=master Code Health

A flatpage is a simple object with a URL, title and content. Use it for one-off, special-case pages, such as “About” or “Privacy Policy” pages, that you want to store in a database but for which you don’t want to develop a custom Django application.

A flatpage can use a custom template or a default, systemwide flatpage template. It can be associated with one, or multiple, sites.

This version is a fork of django.contrib.flatpages package made it multilingual.

Installation

You will need to uninstall flatpages, and remove all traces of it from the INSTALLED_APPS and MIDDLEWARES settings.

To install the multilingual flatpages app, follow these steps:

  1. Install this package:

    $ pip install multilingual_flatpages
  2. Install the sites framework by adding ‘django.contrib.sites’ to your INSTALLED_APPS setting, if it’s not already in there.

  3. Also make sure you’ve correctly set SITE_ID to the ID of the site the settings file represents. This will usually be 1 (i.e. SITE_ID = 1, but if you’re using the sites framework to manage multiple sites, it could be the ID of a different site.

  4. Add ‘multilingual_flatpages’ and ‘parler’ to your INSTALLED_APPS setting.

  5. Add multilingual_flatpages.middleware.FlatpageFallbackMiddleware’ in your MIDDLEWARES list.

  6. Add a TINYMCE_DEFAULT_CONFIG config option in your settings, for example:

    TINYMCE_DEFAULT_CONFIG = {
        'language': 'en',
        'theme': 'modern',
        'height': 600,
        'plugins': [
            'advlist autolink lists link image charmap print preview anchor',
            'searchreplace visualblocks code fullscreen',
            'insertdatetime media table contextmenu paste',
        ],
        'toolbar': 'styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media | code preview',
        'menubar': False,
        'media_alt_source': False,
        'media_poster': False,
        'media_dimensions': False,
    }
  7. Add an entry in your URLconf. For example:

    from multilingual_flatpages import views as multilingual_flatpages_views
    ...
    urlpatterns = [
        url(r'^(?P<flatpage_slug>.*)$', multilingual_flatpages_views.flatpage, name='multilingual_flatpages'),
    ]
  8. Run the command manage.py migrate.

Getting a URL of FlatPage object in your templates

The flatpages app provides a template tag that allows you to get the absolute url depending on your current language.

Like all custom template tags, you’ll need to load its custom tag library before you can use it. After loading the library, you can retrieve all current flatpages URL via the get_flatpage_url tag:

{% load flatpages %}

{% get_flatpage_url 'flatpage-name' %}

You can also use the get_flatpages template tag to get all the FlatPages:

{% load flatpages %}

{% get_flatpages as flatpages %}
<ul>
    {% for page in flatpages %}
        <li><a href="{{ page.get_absolute_url }}">{{ page.title }}</a></li>
    {% endfor %}
</ul>

Getting the URL of the translation of a FlatPage in your template

This is useful if you want to provide a language change link:

{% load flatpages %}
{% get_flatpages as flatpages %}
<ul>
    {% for page in flatpages %}
        <li><a href="{% get_translation_url page 'es'%}">{{ page.title }}</a></li>
    {% endfor %}
</ul>

CHANGELOG

1.0.1 (2026-01-16)

1.0.0 (2026-01-16)

  • Change code for django 5.2 and python 3.11 compatibility.

  • Replace hvad with django-modeltranslations for translations to support modern Django versions and Python 3.11.
    • Update models, forms and admin to use django-modelstranlsations structure.

0.8.3 (2018-06-07)

  • Fix setup.py [urtzai].

0.8.2 (2017-11-29)

  • Fix install_requires [erral]

0.8.1 (2017-11-29)

  • Convert README to RST [erral]

  • Fix requirements.txt [erral]

0.8 (2017-04-07)

0.7 (2017-04-05)

  • Basic test setup [erral]

  • Add a template tag to get translated flatpages [erral]

0.6 (2017-01-20)

0.5 (2017-01-20)

0.4 (2016-11-29)

  • Nothing changed yet.

0.3 (2016-11-29)

  • Nothing changed yet.

0.2 (2016-11-29)

0.1 (2016-11-29)

  • hvad translation system

  • tinymce 4.0.0 editor to the content field

  • Renamed url field to slug

  • Flatpage models, admin, forms to fit hvad translations in: title, content, slug

Metadata

Release files for multilingual-flatpages 1.0.1

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

Source distribution (sdist)

Source distribution for multilingual-flatpages 1.0.1
File Size Uploaded
multilingual_flatpages-1.0.1.tar.gz 60.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for multilingual-flatpages 1.0.1
File Interpreter ABI Platform
multilingual_flatpages-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 207.9 kB

Release files / multilingual_flatpages-1.0.1.tar.gz

Download URL multilingual_flatpages-1.0.1.tar.gz
Size 60.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4b3f1d4ccecdc40564cdf244145b346791ea0a9c9de1c8637c87ff0a8ae82202
BLAKE2b-256 checksum
How to use checksums
360d82b695cf1df8177e1fc1d44de7b47c7741529e4a1823d867be91a96459cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / multilingual_flatpages-1.0.1-py3-none-any.whl

Download URL multilingual_flatpages-1.0.1-py3-none-any.whl
Size 147.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb84a810066ac306b5084fa224b9aeb047fad7f048079747c1d9a12276479306
BLAKE2b-256 checksum
How to use checksums
28bd23f248e382b7699d13b43836711edcda7566cb0a7fb093f1ee5e18e52644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

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