from django.template.defaultfilters import slugify removelist = ["a", "an", "as", "at", "before", "but", "by", "for",\ "from","is", "in", "into", "like", "of", "off", "on",\ "onto","per","since", "than", "the", "this", "that",\ "to", "up", "via","with"] new_topic = "this is a test with a long string which has many words up to here." clean_list = [str(word) for word in new_topic.split() if word not in removelist] new_slug = slugify(clean_list)