1π
β
From this answer
You can do something like this:
import random
import string
def index(request):
registerform = UserRegisterForm()
if request.method == 'POST':
if 'password' in request.POST:
registerform = UserRegisterForm(request.POST)
if registerform.is_valid():
username = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))
result = registerform.save(commit=False)
result.set_password(request.POST['password'])
result.username = username
result.save()
member.user_id = user.id
member.member_id = result.id
member.save()
''''
return render(request,'index.html',{'registerform': registerform,})
0π
Please see if you can use this.
import random
l = list(map(chr, range(97, 123)))
random.shuffle(l)
''.join(l)[0:7]
π€user2598057
- [Answer]-Tango with Django tutorial: "table rango_category has no column named views"
- [Answer]-Django sends email to some weird "m, m" address
- [Answer]-JQuery Qtip2 text over multiple lines (in Django project)
- [Answer]-Relation error on adding new model class
Source:stackexchange.com