Esempio n. 1
0
def slugify(value):
    """
        unicodedata (lib Django's slugify is using) does not recognize
        đ and Đ, and therefore omits them. We manually replace them with
        d and D.
    """
    return _slugify(value.replace(u'đ', u'd').replace(u'Đ', u'D'))
Esempio n. 2
0
def slugify(model, text):
    """
    Make a unique slug for an object of the given model with the given text.
    
    Assumes the slug field is called 'slug'.
    """
    slug = _slugify(text)
    same_slug_count = model.objects.filter(slug__iregex=slug + '(-\d+)?').count()
    if same_slug_count:
        slug = "%s-%d" % (slug, same_slug_count)
    return slug
Esempio n. 3
0
def slugify(value, length=MAX_SLUG_LENGTH):
    """runs the given value through django's slugify filter and slices it to a given length

    :param value: the value you want turned into a slug
    :type value: str

    :param length: the maximum length of the slug
    :type length: int

    :return: the slugified version of the input value sliced to the length value
    :rtype: str
    """
    slug = _slugify(value)[:length]
    while slug.endswith("-"):
        slug = slug[:-1]
    return slug
Esempio n. 4
0
def slugify(text):
	return _slugify(text).replace('-','_')
Esempio n. 5
0
def produto_pre_save(signal, instance, sender, **kwargs):
    instance.slug = _slugify(instance.nome)
Esempio n. 6
0
def slugify(string):
    return _slugify(string).replace('-', '')
Esempio n. 7
0
def _sql_paths(*args):
    args = [str(arg) for arg in args]
    args.append(_slugify(_get_branch_name(False)))
    return _slugify('-'.join(args)) + '.sql.gz'
Esempio n. 8
0
def slugify(value):
    return _slugify(unidecode(str(value)))
Esempio n. 9
0
def slugify(value):
    value = value.replace(u'æ', 'ae').replace(u'ø', 'o').replace(u'å', 'aa')
    value = value.replace(u'ö', 'o').replace(u'ä', 'aa')
    return _slugify(value)
Esempio n. 10
0
def slugify(s):
    from django.template.defaultfilters import slugify as _slugify
    from unidecode import unidecode
    s = unidecode(s)
    return _slugify(s)