def create_unique_slug(cls, user): # Create the slug to identify the user slug = random_word(10) # Ensure that slug is unique while sas.query(SlugIdentification).filter(SlugIdentification.user_slug == slug).first(): slug = random_word(10) # And return a SlugIdentification instance with the slug return SlugIdentification(user_slug=slug, user=user)
def __init__(self, user): self.key = random_word(20) self.user = user