Cristian Rojas
Cristian Rojas

Reputation: 2862

Django is printing month name in english even when LANGUAGE_CODE is 'es-CO'

I've a Django project where I'm trying to render the month name inside a template with the date template tag.

In my settings.py I've the following because this app runs in Colombia (should be in spanish)

LANGUAGE_CODE = 'es-CO'
USE_L10N = True

In the template I'm trying to format the date this way:

{{ car.expiration_date|date:'F' }}

According with the documentation the F returns the month's full name and that's true but is coming in english instead of spanish.

I have other Django projects working properly with these settings but I can't find the reason because this one isn't.

Upvotes: 2

Views: 2691

Answers (2)

klasske
klasske

Reputation: 2184

If you have no other way of setting the language code for this particular template, you could try to render the date in your email templateby switching to the right language:

{% load i18n %}

{% language 'es-co' %} {{ car.expiration_date|date:'F' }} {% endlanguage %}

See documentation

Upvotes: 1

François Constant
François Constant

Reputation: 5496

Have you tried:

  • to restart the server
  • pip freeze to check the Django version => double check that there is no change
    • maybe USE_I18N // USE_L10N
  • a search on LANGUAGE_CODE in your code just in case

This in a view somewhere or in the Django shell just to to be sure:

from django.conf import settings
print settings.LANGUAGE_CODE
print settings. …

Upvotes: 0

Related Questions