skip to navigation
skip to content

solid_i18n 1.2.0

Use default language for urls without language prefix (django)

Django solid_i18n urls

solid_i18n contains middleware and url patterns to use default language at root path (without language prefix).

Default language is set in settings.LANGUAGE_CODE.


  • python (2.7, 3.4, 3.5)
  • django (1.8, 1.9)

Release notes



There are two modes:

  1. settings.SOLID_I18N_USE_REDIRECTS = False (default). In that case i18n will not use redirects at all. If request doesn’t have language prefix, then default language will be used. If request does have prefix, language from that prefix will be used.
  2. settings.SOLID_I18N_USE_REDIRECTS = True. In that case, for root paths (without prefix), django will try to discover user preferred language. If it doesn’t equal to default language, redirect to path with corresponding prefix will occur. If preferred language is the same as default, then that request path will be processed (without redirect). Also see notes below.

Quick start

  1. Install this package to your python distribution:

    pip install solid_i18n
  2. Set languages in

    # Default language, that will be used for requests without language prefix
    LANGUAGE_CODE = 'en'
    # supported languages
        ('en', 'English'),
        ('ru', 'Russian'),
    # enable django translation
    USE_I18N = True
    # Optional. If you want to use redirects, set this to True
  3. Add SolidLocaleMiddleware instead of LocaleMiddleware to MIDDLEWARE_CLASSES:

  4. Use solid_i18n_patterns instead of i18n_patterns

    from django.conf.urls import patterns, include, url
    from solid_i18n.urls import solid_i18n_patterns
    urlpatterns = solid_i18n_patterns('',
        url(r'^about/$', 'about.view', name='about'),
        url(r'^news/', include(news_patterns, namespace='news')),
  5. Start the development server and visit to see english content. Visit to see russian content. If SOLID_I18N_USE_REDIRECTS was set to True and if your preferred language is equal to Russian, request to path will be redirected to But if preferred language is English, will be shown.


    If True, redirect to url with non-default language prefix from url without prefix, if user’s language is not equal to default. Otherwise url without language prefix will always render default language content (see behaviour section and notes for details).
    If True, both urls /... and /en/... will render default language content (in this example ‘en’ is default language). Otherwise, /en/... will return 404 status_code.
    If True, redirect from url with default language prefix to url without any prefix, i.e. redirect from /en/... to /... if ‘en’ is default language.

Example site

Located here, it is ready to use, just install solid_i18n (this package):

pip install solid_i18n

clone example site:

git clone

step in example/ and run development server:

cd django-solid-i18n-urls/example
python runserver


  • When using SOLID_I18N_USE_REDIRECTS = True, there is some nasty case. Suppose django has determined user preferred language incorrectly (maybe in user’s browser preferred language is not equal to his realy preferred language, because for example it is not his computer) and it is Russian. Then on access to url without prefix, i.e. '/', he will be redirected to '/ru/' (according to browsers preferred language). He wants to look english content (that is default language), but he can’t, because he is always being redirected to '/ru/' from '/'. To avoid this, it is needed to set preferred language in his cookies (just <a href="{{ specific language url}}"> will not work). For that purporse django’s set_language redirect view shall be used. See example in this package.
  • Of course, you must specify translation for all languages you’ve marked as supported. For details look here:
  • Don’t mix together settings SOLID_I18N_HANDLE_DEFAULT_PREFIX and SOLID_I18N_DEFAULT_PREFIX_REDIRECT. You should choose only one of them.

solid_i18n release notes


  • Add django 1.9 support
  • Drop django 1.4 support
  • Drop python 3.2 support
  • Simplify tox settings

Issues: #32, #23, #21


  • fix django 1.8 AppRegistryNotReady("Apps aren't loaded yet.")

Issues: #29


  • Use 301 redirect in case of SOLID_I18N_DEFAULT_PREFIX_REDIRECT
  • Upload wheel

Issues: #24, #20


  • Add django 1.8 support

Issues: #8, #19


  • fix working with set_language and SOLID_I18N_HANDLE_DEFAULT_PREFIX = True

Issues: #17


  • fix url reverse in case of SOLID_I18N_HANDLE_DEFAULT_PREFIX = True
  • simplify django version checking

Issues: #13, #14



Issues: #12


  • handle urls with default language prefix explicitly set

Issues: #10


  • add django 1.7 support
  • add python 3.4 support

Issues: #6


  • fix http header ‘Vary Accept-Language’

Issues: #4


  • stop downgrading Django from 1.6.x to 1.6
  • include requirements.txt in distribution
  • minor docs updates

Issues: #3


Add python 3.2, 3.3 support.

Issues: #2


Add django 1.6 support


Update README and data for pypi


First version in pypi

File Type Py Version Uploaded on Size
solid_i18n-1.2.0-py2.py3-none-any.whl (md5) Python Wheel 2.7 2016-03-13 12KB
solid_i18n-1.2.0.tar.gz (md5) Source 2016-03-13 11KB
  • Downloads (All Versions):
  • 0 downloads in the last day
  • 0 downloads in the last week
  • 1294 downloads in the last month