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

I am trying to integrate django-transmeta into my django installation on ubuntu 10.10 (the python-django version on the system is 1.2.3-1ubuntu0.2.10.10.1) Following the instructions in the home / summary project 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 "description" does not appear in the admin panel, and it only displays No. Looking at the source code and after a little debugging, the variable passed to the template is set to No , it looks like 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 file, I added the following:

 LANGUAGE_CODE = 'en-us' ugettext = lambda s: s # dummy ugettext function, as django 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 not send images in questions for anti-spam reasons, yet) screenshot of the administrator here

The admin form above should be something like:

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

Do you have an idea what might be the problem? Or maybe this is a mistake?

To improve debugging, can you kindly tell me the place in the correct django admin view where field.label_tag is generated? (I'm new to Django)

If you need some debugging data, let me know and I will gladly provide it.

Thank you in advance

Fabio

+4
source share
1 answer

It looks like your fields are missing the verbose_name attributes.

 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 
+5
source

Source: https://habr.com/ru/post/1346534/


All Articles