def slugify_uniquely_for_queryset(value, queryset, slugfield='slug'):
 suffix = 0
 potential = base = django_slugify(unidecode(value))
 if (len(potential) == 0):
  potential = 'null'
 while True:
  if suffix:
   potential = '-'.join([base, str(suffix)])
  if (not queryset.filter(**{slugfield: potential}).exists()):
   return potential
  suffix += 1

def slugify_uniquely_for_queryset ( value , queryset , slugfield = 'slug' ) : suffix = 0 potential = base = django_slugify ( unidecode ( value ) ) if ( len ( potential ) == 0 ) : potential = 'null' while True : if suffix : potential = '-' . join ( [ base , str ( suffix ) ] ) if ( not queryset . filter ( ** { slugfield : potential } ) . exists ( ) ) : return potential suffix += 1
returns a slug on a name which doesnt exist in a queryset .