Skip to content

Commit

Permalink
added __unicode__ method to BaseTranslationModel and move get_languag…
Browse files Browse the repository at this point in the history
…e_name to models.py
  • Loading branch information
rvikmanis committed Dec 23, 2011
1 parent c2d5630 commit db357b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions nani/admin.py
Expand Up @@ -22,15 +22,14 @@
from functools import update_wrapper
from nani.forms import TranslatableModelForm
from nani.utils import get_cached_translation, get_translation
from nani.models import get_language_name
import django
import urllib


NEW_GET_DELETE_OBJECTS = LooseVersion(django.get_version()) >= LooseVersion('1.3')


def get_language_name(language_code):
return dict(settings.LANGUAGES).get(language_code, language_code)

class CleanMixin(object):
def clean(self):
Expand Down
6 changes: 6 additions & 0 deletions nani/models.py
Expand Up @@ -7,7 +7,10 @@
from nani.manager import TranslationManager, TranslationsModelManager
from nani.utils import SmartGetFieldByName
from types import MethodType
from django.conf import settings

def get_language_name(language_code):
return dict(settings.LANGUAGES).get(language_code, language_code)

def create_translations_model(model, related_name, meta, **fields):
"""
Expand Down Expand Up @@ -77,6 +80,9 @@ def __init__(self, *args, **kwargs):

class Meta:
abstract = True

def __unicode__(self):
return get_language_name(self.language_code)


class TranslatableModelBase(ModelBase):
Expand Down

0 comments on commit db357b1

Please sign in to comment.