from django.contrib.auth.models import User password = User.objects.make_random_password() user.set_password(password) user.save()