Browse Source

Tiny improvement in slugs generation.

Rafał Pitoń 11 years ago
parent
commit
6bdb12bfef
2 changed files with 3 additions and 3 deletions
  1. 1 1
      misago/utils/strings.py
  2. 2 2
      misago/validators.py

+ 1 - 1
misago/utils/strings.py

@@ -10,7 +10,7 @@ def slugify(string):
     string = unicode(string)
     if use_unidecode:
         string = unidecode(string)
-    return django_slugify(string)
+    return django_slugify(string).replace('_', '-')
 
 
 def random_string(length):

+ 2 - 2
misago/validators.py

@@ -11,8 +11,8 @@ class validate_sluggable(object):
         self.error_long = error_long if error_long else _("Value is too long.")
 
     def __call__(self, value):
-        slug = slugify(value.replace('_', '').replace('-', ''))
-        if not slug:
+        slug = slugify(value)
+        if not slug.replace('-', ''):
             raise ValidationError(self.error_short)
         if len(slug) > 255:
             raise ValidationError(self.error_long)