示例#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'))
示例#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
示例#3
0
文件: slugs.py 项目: vforgione/bulbs2
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
示例#4
0
def slugify(text):
	return _slugify(text).replace('-','_')
示例#5
0
def produto_pre_save(signal, instance, sender, **kwargs):
    instance.slug = _slugify(instance.nome)
示例#6
0
def slugify(string):
    return _slugify(string).replace('-', '')
示例#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'
示例#8
0
def slugify(value):
    return _slugify(unidecode(str(value)))
示例#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)
示例#10
0
def slugify(s):
    from django.template.defaultfilters import slugify as _slugify
    from unidecode import unidecode
    s = unidecode(s)
    return _slugify(s)