Hi, I am having a bit of a problem. I have a model with 3 name fields, each for a different language. By creating an __unicode__ function like below, I always get the correct name for the current language. Works fine.
But, I want to change the default ordering for this model, so that in each language, the correct order is used. Sadly, this doesn't work, as I get the error "NameError: name 'Substrate' is not defined". Also "self" and "super" don't seem to work. I just can't seem to be able to access the parent class from within the Meta class. I can't even repeat the getLanguage function into the Meta class, because then I get an the error "TypeError: 'class Meta' got invalid attribute(s): getLanguage". class Substrate(models.Model): name_en = models.CharField(max_length=255) name_de = models.CharField(max_length=255, blank=True) name_nl = models.CharField(max_length=255, blank=True) def getLanguage(self): from django.utils import translation current_language = translation.get_language() if not current_language: current_language = 'en' return current_language def getName(self): current_language = self.getLanguage() name = getattr(self, 'name_'+current_language, self.name_en) if not name: name = self.name_en return name def __unicode__(self): return self.getName() class Meta: ordering = [('name_%s' % Substrate.getLanguage()), 'name_en'] If anyone has an idea how on to do this, I would be very happy. Thanks! Cheers, Kevin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.