Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create random password? create_user function [duplicate]

Tags:

django

Possible Duplicate:
Django Password Generator

d = Data.objects.get(key=key)    
User.objects.create_user(username = d.name, email= d.email, password =  password)

How to create random password and send this via e-mail to user (d.email) ?

like image 815
mamasi Avatar asked Feb 05 '13 11:02

mamasi


People also ask

How are random passwords generated?

A random password generator is software program or hardware device that takes input from a random or pseudo-random number generator and automatically generates a password. Random passwords can be generated manually, using simple sources of randomness such as dice or coins, or they can be generated using a computer.

What is password randomization?

A random password generator is a software program, hardware device, or online tool that automatically generates a password using parameters that a user sets, including mixed-case letters, numbers, symbols, pronounceability, length, and strength.


2 Answers

in django make_random_password is a built in method for generating random password

my_password = User.objects.make_random_password()

it accepts parameters as length and allowd_chars with that you can limit the password length and special symbols and numbers

like image 124
kartheek Avatar answered Oct 01 '22 14:10

kartheek


def view_name(request):
    #make random password
    randompass = ''.join([choice('1234567890qwertyuiopasdfghjklzxcvbnm') for i in range(7)])

    #sending email
    message = "your message here"
    subject = "your subject here"
    send_mail(subject, message, from_email, ['to_email',])
like image 26
catherine Avatar answered Oct 01 '22 16:10

catherine