change to smart_str for py3

This commit is contained in:
Val Neekman 2014-03-08 09:02:56 -05:00
parent 240d89c62a
commit bc62fa2144

View file

@ -2,7 +2,13 @@
__version__ = '1.0.2'
from django.utils.encoding import smart_unicode
from django.utils import six
if six.PY3:
from django.utils.encoding import smart_unicode as smart_str
else:
from django.utils.encoding import smart_str
from slugify import slugify as pyslugify
__all__ = ['slugify', 'uuslug']
@ -11,7 +17,7 @@ __all__ = ['slugify', 'uuslug']
def slugify(text, entities=True, decimal=True, hexadecimal=True, max_length=0, word_boundary=False, separator='-'):
""" Make a slug from a given text """
return smart_unicode(pyslugify(text, entities, decimal, hexadecimal, max_length, word_boundary, separator))
return smart_str(pyslugify(text, entities, decimal, hexadecimal, max_length, word_boundary, separator))
def uuslug(s, instance, entities=True, decimal=True, hexadecimal=True,