def generate_valid_slug(source, parent, language):
 if parent:
  qs = Title.objects.filter(language=language, page__parent=parent)
 else:
  qs = Title.objects.filter(language=language, page__parent__isnull=True)
 used = list(qs.values_list('slug', flat=True))
 baseslug = slugify(source)
 slug = baseslug
 i = 1
 if used:
  while (slug in used):
   slug = ('%s-%s' % (baseslug, i))
   i += 1
 return slug

def generate_valid_slug ( source , parent , language ) : if parent : qs = Title . objects . filter ( language = language , page__parent = parent ) else : qs = Title . objects . filter ( language = language , page__parent__isnull = True ) used = list ( qs . values_list ( 'slug' , flat = True ) ) baseslug = slugify ( source ) slug = baseslug i = 1 if used : while ( slug in used ) : slug = ( '%s-%s' % ( baseslug , i ) ) i += 1 return slug
generate a valid slug for a page from source for the given language .