views:

32

answers:

2

Hello I need to have multiple language support of my django admin application.I can create the messege files.But how can i change the text of my models.The heading ,fields etc .I m only able to change the static elements which are there in my template.

here is example of my class

class Mymodel(model.Models):
      id=models.IntegerField(primary_key=true)
      name=models.CharField(max_length=200)
      group=models.CharField(max_length=200)

      class Meta:
            managed=False
            verbose_name_plural='My admin'
            db_table='my_admin'

one more question.In my home page it is showing my verbose name 'My admin' which i mentioned.But when i go to list page it shows me the class name 'mymodel'.Why so.Can i changed that to

A: 

you can pass the "name" of a field as the first parameter like this:

class Event(models.Model):

    name = models.CharField('name', max_length=50, unique=True)
    start = models.DateTimeField('start')
    end = models.DateTimeField('end')
    ressource = models.ForeignKey(Resource, related_name='events')

if you want to i18n that you just use the gettext-lib from django like this:

from django.utils.translation import ugettext_lazy as _

class Event(models.Model):

name = models.CharField(_('name'), max_length=50, unique=True)
start = models.DateTimeField(_('start'))
end = models.DateTimeField(_('end'))
ressource = models.ForeignKey(Resource, related_name='events')
renton
this is not working if i am having a field name as follows head_name=models.CharField(_('Head ame'),max_length=200)in my .po file it is adding #fuzzy before the field name and it not converting it.But if i used ugettext and mention my field like head_name=models.CharField(ugettext("HeadName"),max_length=200)and then remove #fuzzy from .po file it is working fine.
ha22109