1. Jannis Leidel
  2. django-autoslug


Andy Mikhailenko  committed f04cabc

If custom slugify function is not defined, try to import one from pytils and only then fall back to Django's default.

  • Participants
  • Parent commits a63258e
  • Branches default

Comments (0)

Files changed (1)

File autoslugfield/settings.py

View file
  • Ignore whitespace
 from django.conf import settings
-""" the AUTOSLUGFIELD_SLUGIFY_FUNCTION setting allows to define
+""" the AUTOSLUG_SLUGIFY_FUNCTION setting allows to define
 a custom slugifying function. Value can be a string or a callable.
 Default value is 'django.template.defaultfilters.slugify'.
-slugify = getattr(settings, 'AUTOSLUGFIELD_SLUGIFY_FUNCTION', # use custom slugifying function...
-    'django.template.defaultfilters.slugify' # ...or fall back to Django's default one
+# use custom slugifying function if any 
+slugify = getattr(settings, 'AUTOSLUG_SLUGIFY_FUNCTION', None)
+if not slugify:
+    try:
+        # more i18n-friendly slugify function (supports Russian transliteration)
+        from pytils.translit import slugify
+    except ImportError:
+        # fall back to Django's default one
+        slugify = 'django.template.defaultfilters.slugify'
+# find callable by string
 if isinstance(slugify, str):
     from django.core.urlresolvers import get_callable
     slugify = get_callable(slugify)