- Author:
- lawgon
- Posted:
- November 9, 2009
- Language:
- HTML/template
- Version:
- Not specified
- Score:
- 3 (after 3 ratings)
you have a multilingual site and need to change languages in admin. Previously this was easy in the site itself and more difficult in admin. Now it is dead easy. Set up your languages in settings.py. Make a directory called 'admin' in your templates directory, copy ~/django/contrib/admin/templates/base.html to that directory. Add the following code (below breadcrumbs is a good place)
this will give you a switcher for all installed languages. You would need to refresh the browser on changing the language.
1 2 3 4 5 6 7 8 9 | <form action="/i18n/setlang/" method="post">
<select name="language">
{% for lang in LANGUAGES %}
<option value="{{ lang.0 }}" {% ifequal lang.0 request.LANGUAGE_CODE %}selected="yes"
{% endifequal %}>{{ lang.1 }}</option>
{% endfor %}
</select>
<input type="submit" value="Go" />
</form>
|
More like this
- Bootstrap Accordian by Netplay4 5 years, 11 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 11 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 11 months ago
- Reusable form template with generic view by roldandvg 9 years ago
- Pagination Django with Boostrap by guilegarcia 9 years, 2 months ago
Comments
This wouldn't work for me (Django 1.2.3) without adding
'django.middleware.locale.LocaleMiddleware',
toMIDDLEWARE_CLASSES
#
Please login first before commenting.