Answer the question
In order to leave comments, you need to log in
Is it possible to organize user registration in Django this way?
Let's say I have a user model User (name, position). Django already has a User model from AUTHENTICATION AND AUTHORIZATION. Django also provides its ready-made registration forms: UserCreationForm. In the template, the form can be rendered like this: {{form}}. Three fields are displayed: username, password1, password2. The fact is that I did not understand what the condition checks: form.is_valid (), so I did without it (I check it manually). I found an option on the Internet where there is a Profile model that contains (I have this User):
user = models.OneToOneField(User, on_delete=models.CASCADE)
#+свои поля
username = request.POST.get('username')
password1 = request.POST.get('password1')
password2 = request.POST.get('password2')
signup_f = request.POST.get('signup_f')
signup_i = request.POST.get('signup_i')
signup_o = request.POST.get('signup_o')
signup_post = request.POST.get('signup_post')
signup_email = request.POST.get('signup_email')
pattern = compile('(^|\s)[-a-z0-9_.][email protected]([-a-z0-9]+\.)+[a-z]{2,6}(\s|$)')
if(password1 == password2) and (pattern.match(signup_email)):
user_auth = AuthUser.objects.create_user(username, signup_email, password1)
user_auth.save()
user = User(fio=signup_f+' '+signup_i+' '+signup_o, user_post=signup_post, group=1, email=signup_email)
user.save()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question