views.py
def index(request):
    registerform = UserRegisterForm()
    if request.method == 'POST':
        if 'password' in request.POST:
            registerform = UserRegisterForm(request.POST)    
            if registerform.is_valid():
                result = registerform.save(commit=False)
                result.set_password(request.POST['password'])       
                result.save()
                member.user_id = user.id
                member.member_id = result.id
                member.save() 
          ''''
    return render(request,'index.html',{'registerform': registerform,})
forms.py
class UserRegisterForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ['username','first_name', 'last_name', 'email', 'password', 'is_staff', 'is_active']
I am saving the form fields via form.
The username field is included in the form. In the template, I made the username field hidden. How would I create a username with random string while creating the user profile?
 
     
     
    