开发者

django-transmeta into admin, displaying "None" in the field.label_tag

I'm trying to integrate django-transmeta into my django installation on ubuntu 10.10 (python-django version on system is 1.2.3-1ubuntu0.2.10.10.1) Following the instructions in the project home/summary here I end up with the correct new fields in the database, but when I open the admin interface and I try to add an object, the translated filed "description" is not shown in the admin panel and it's shown only None. Looking in the source code and after a bit of debug, the variable passed to the template which the value is None seems to be field.label_tag

This is the class inside models.py:

class Place(models.Model):
__metaclass__ = TransMeta
lat = models.FloatField(blank=True, null=True)
lon = models.FloatField(blank=True, null=True)
alt = models.FloatField(blank=True, null=True)
description = models.CharField(max_length=100)
address = models.CharField(max_length=50)
city = models.CharField(max_length=60)
state_province = models.CharField(max_length=30)
country = models.CharField(max_length=50)
attributes = models.ManyToManyField(Attribute, through='PlaceAttribute')
is_online = models.BooleanField(default=False)
class Meta:
    translate = ('description', )
def __unicode__(self):
    return self.description

In the settings.py I added this:

LANGUAGE_CODE = 'en-us'

ugettext = lambda s: s # dummy ugettext function, as django's docs say

LANGUAGES = (
    ('en-us', ugettext('English')),
    ('it', ugettext('Italian')),
    ('de', ugettext('Deutsch')),
    ('fr', ugettext('French')),
    ('ru', ugettext('Russian')),
    ('cn', ugettext('Chinese')),
    ('th', ugettext('Thai')),
)

TRANSMETA_DEFAULT_LANGUAGE = 'en-us'

and this is a screenshot of the result in the admin interface: (sorry I'm new here and can't post images in questions for antispam reasons, yet) admin screenshot here

In the above admin form it should be something like:

Description en-us:
Description it:
Description de: 
....

Have you an idea of what could the problem be? Or maybe it's a bug?

To improve my debug, could you kindly point me in the correct place inside the django admin view where the field.label_tag is generated? (I'm quite new to Django)

If some debug data is needed, please tell me and I'll gladly provide it.

Thanks in adva开发者_StackOverflow社区nce

Fabio


It looks like you're missing verbose_name attributes on your fields.

from django.utils.translation import gettext_lazy as _

class Place(models.Model):
    __metaclass__ = TransMeta
    # ...
    description = models.CharField(max_length=100, verbose_name=_("Description"))
    # ...

    class Meta:
        translate = ('description', )

    def __unicode__(self):
        return self.description
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜