Exemple #1
0
 def __call__(self, meta, name, *args, **kwargs):
     try:
         return self.real(name, *args, **kwargs)
     except FieldDoesNotExist as e:
         try:
             meta.translations_model._meta.get_field(name, *args, **kwargs)
         except FieldDoesNotExist:
             raise e
         else:
             raise WrongManager(meta, name)
Exemple #2
0
 def __call__(self, meta, name):
     assert not isinstance(self.real, SmartGetFieldByName)
     try:
         return self.real(name)
     except FieldDoesNotExist as e:
         try:
             meta.translations_model._meta.get_field_by_name(name)
         except FieldDoesNotExist:
             raise e
         else:
             raise WrongManager(meta, name)
Exemple #3
0
 def __call__(self, meta, name):
     assert not isinstance(self.real, SmartGetFieldByName)
     try:
         return self.real(name)
     except FieldDoesNotExist:
         if name in meta.translations_model._meta.get_all_field_names():
             raise WrongManager(
                 "To access translated fields like %r from "
                 "an untranslated model, you must use a "
                 "translation aware manager, you can get one "
                 "using "
                 "hvad.utils.get_translation_aware_manager." % name)
         raise
Exemple #4
0
 def __call__(self, meta, name, *args, **kwargs):
     try:
         return self.real(name, *args, **kwargs)
     except FieldDoesNotExist as e:
         try:
             meta.translations_model._meta.get_field(name, *args, **kwargs)
         except FieldDoesNotExist:
             raise e
         else:
             raise WrongManager("To access translated fields like %r from "
                                "an untranslated model, you must use a "
                                "translation aware manager. For non-translatable "
                                "models, you can get one using "
                                "hvad.utils.get_translation_aware_manager.\n"
                                "For translatable models, use the language() "
                                "method." % name)