Skip to content

Commit

Permalink
replaced __unicode__ with __str__ in hvad model mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Lorenz committed Apr 11, 2016
1 parent 55c9b97 commit 7b18815
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django_libs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '1.67'
__version__ = '1.67.1'
4 changes: 3 additions & 1 deletion django_libs/models_mixins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Useful mixins for models."""
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import get_language

from hvad.models import NoTranslation, TranslationManager
Expand All @@ -25,9 +26,10 @@ def published(self, request, check_language=True):
return self.get_queryset().filter(**kwargs)


@python_2_unicode_compatible
class TranslationModelMixin(object):
"""Mixin to provide custom django-hvad overrides."""
def __unicode__(self):
def __str__(self):
return self.translation_getter('title')

def check_for_result(self, language, translation, result, name):
Expand Down
2 changes: 1 addition & 1 deletion docs/models_mixins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can use this by inheriting the class::
),
)

This mixin will automatically return the title field if its ``__unicode__``
This mixin will automatically return the title field if its ``__str__``
function is called and it will always return a title string (no pk fallback or
anything like that needed). If there's no translation available in the current
language it searches for others.

0 comments on commit 7b18815

Please sign in to comment.