Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#10582 closed (invalid)

Gettext Translation are not translated by django in the admin in a Form Override

Reported by: andreac81@… Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords: translation i18n admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

This is the problem that i have found.
I have created a simple model like this:

from django.db import models
from django.utils.translation import ugettext_lazy as _

# Create your models here.

class Test(models.Model):
    simple_test = models.TextField(_("simple text"))

Then, for some reasons, i want to customize the behaviour of the admin interface, so i want to define
a special form for my model. So there is the code:

from testapp.models import Test
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django import forms

class MyTestForm(forms.ModelForm):
    simple_test = forms.CharField(_('simple text'))

    class Meta:
        model = Test

class MyTestAdmin(admin.ModelAdmin):
    form = MyTestForm, MyTestAdmin)

So, after giving the usual commands django-admin makemessages -l it and django-admin compilemessages, and after writing
the translation in the django.po file, i can't get the translation.
Instead if i change the line:, MyTestAdmin)


everything works fine.

Attachments (1)

translation_test.tar.gz (3.0 KB) - added by andreac81@… 11 years ago.
Test case (create the db with syncdb)

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by andreac81@…

Attachment: translation_test.tar.gz added

Test case (create the db with syncdb)

comment:1 Changed 11 years ago by Ramiro Morales

Description: modified (diff)

(reformatted description)

comment:2 Changed 11 years ago by dc

Resolution: invalid
Status: newclosed

Not a Django bug, but yours. Use label:

class MyTestForm(forms.ModelForm):
    simple_test = forms.CharField(label=_('simple text'))

comment:3 Changed 8 years ago by Jacob

milestone: 1.0.3

Milestone 1.0.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top