1
0
mirror of https://github.com/django/django.git synced 2025-07-04 09:49:12 +00:00

unicode: Changed the place where we compute verbose_name_raw. It's done

on-demand now, rather than in contribute_to_class(), which was causing problems.


git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5345 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-05-26 06:55:09 +00:00
parent e4cb94415e
commit 087bf45d93

View File

@ -43,14 +43,6 @@ class Options(object):
self.module_name = self.object_name.lower()
self.verbose_name = get_verbose_name(self.object_name)
# There are a few places where the untranslated verbose name is needed
# (so that we get the same value regardless of currently active
# locale).
lang = get_language()
deactivate_all()
self.verbose_name_raw = unicode(self.verbose_name)
activate(lang)
# Next, apply any overridden values from 'class Meta'.
if self.meta:
meta_attrs = self.meta.__dict__
@ -101,7 +93,20 @@ class Options(object):
def __str__(self):
return "%s.%s" % (self.app_label, self.module_name)
def verbose_name_raw(self):
"""
There are a few places where the untranslated verbose name is needed
(so that we get the same value regardless of currently active
locale).
"""
lang = get_language()
deactivate_all()
raw = unicode(self.verbose_name)
activate(lang)
return raw
verbose_name_raw = property(verbose_name_raw)
def get_field(self, name, many_to_many=True):
"Returns the requested field by name. Raises FieldDoesNotExist on error."
to_search = many_to_many and (self.fields + self.many_to_many) or self.fields