def user_edit(request, id): errors = '' user = User.objects.get(id=id) if request.method == 'POST': user_form = UserForm(request.POST, request.FILES, instance=user) csrf = Csrf.objects.get(session=request.session.session_key) if csrf.csrf != request.POST.get('csrfmiddlewaretoken'): csrf.csrf = request.POST.get('csrfmiddlewaretoken') csrf.save() if request.POST.get('password'): password_p = re.compile(r"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}") password = request.POST.get('password') if password_p.match(password): if user_form.is_valid(): user_form.save() user.set_password(request.POST['password']) user.save() return redirect(reverse('auth_user')) else: errors = user_form.errors else: errors = "密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间" else: if user_form.is_valid(): user_form.save() return redirect(reverse('auth_user')) else: errors = user_form.errors else: user_form = UserForm(instance=user) return render(request, 'user_change.html', {'user_forms': user_form, 'use': user, 'errors': errors})
def signup(request): if request.POST: try: form = UserForm(request.POST) if form.is_valid(): user = form.save() user.first_name = form.cleaned_data['first_name'] user.last_name = form.cleaned_data['last_name'] user.username = form.cleaned_data['username'] user.email = form.cleaned_data['email'] user.password = form.cleaned_data['password'] user.password_confirm = form.cleaned_data['password_confirm'] user.set_password(user.password) user.save() return HttpResponseRedirect('/user/login') else: form.add_error(None, "Please enter all fields correctly") except IntegrityError: form.add_error(None, "Username is already taken") return render(request, 'accounts/create.html', {'form': form}) else: form = UserForm() return render(request, 'accounts/create.html', {'form': form})
def post(self, request): session_code = request.session.get('random_code') # 强制转换成真正的字典 print(session_code) data = request.POST.dict() data['session_code'] = session_code # 2. 处理数据 form = UserForm(data) # code = data.cleaned_data.get("verify_code") print(form) if form.is_valid(): # 参数合法 # 获取值 data = form.cleaned_data phone = data.get('phone') password = data.get('password1') # 写入数据 User.objects.create(phone=phone, password=password) url = reverse("user:登陆页面") return redirect(url) else: # 参数不合法 # 获取错误信息 context = {"form": form} return render(request, "user/reg.html", context)
def settings(request): if request.method == "POST": # First and last name user_form = UserForm(request.POST, request.FILES, instance=request.user) if user_form.is_valid(): user_form.save() messages.add_message(request, messages.INFO, "Profile updated!") return redirect("user_settings") else: errors = ",".join( map(lambda err: str(err[0]), user_form.errors.values())) messages.add_message( request, messages.ERROR, user_form.non_field_errors().as_text() + errors) token, _ = Token.objects.get_or_create(user=request.user) user_form = UserForm(instance=request.user) return render( request, "user/settings.html", { "token": token.key, "user_form": user_form, "user_change_password_form": PasswordChangeForm(user=request.user), }, )
def register(request): #is registration successful registered = False if request.method == 'POST': user_form = UserForm(data=request.POST) profile_form = UserProfileForm(data=request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() #hash password user.set_password(user.password) user.save() # commit - we need to set the user attribute our selves profile = profile_form.save(commit=False) profile.user = user profile.save() registered = True else: print user_form.errors, profile_form.errors else: user_form = UserForm() profile_form = UserProfileForm() return render(request, 'user/register.html', { 'user_form': user_form, 'profile_form': profile_form, 'registered': registered })
def user_register(request): if request.method == "GET": user_form = UserForm() elif request.method == "POST": user_form = UserForm(request.POST) if user_form.is_valid(): user = user_form.save() user.save() password = user.password # The form doesn't know to call this special method on user. user.set_password(password) user.save() # You must call authenticate before login. :( user = authenticate(username=user.username, password=password) login(request, user) messages.add_message( request, messages.SUCCESS, "Congratulations, {}, on creating your new account! You are now logged in.".format( user.username)) return redirect('index') return render(request, "user/register.html", {'user_form': user_form, })
def post(self, request): form = UserForm(request.POST) if form.is_valid(): newUser = BlogUser() newUser.first_name = form.cleaned_data['first_name'] newUser.last_name = form.cleaned_data['last_name'] newUser.email = form.cleaned_data['email'] newUser.set_password(form.cleaned_data['password']) newUser.username = form.cleaned_data['email'] newUser.save() return JsonResponse({"status": 0}) if form.non_field_errors(): return JsonResponse( { 'status': -1, 'message': form.non_field_errors()[0] }, status=404) else: return JsonResponse({ 'status': -1, 'message': "can't be empty" }, status=404)
def register(request): registered = False if request.method == 'POST': user_form = UserForm(request.POST) user_detail_form = UserDetailForm(request.POST, request.FILES) if user_form.is_valid() and user_detail_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = user_detail_form.save(commit=False) profile.user = user if 'profile_picture' in request.FILES: print('found profile picture') profile.profile_picture = request.FILES['profile_picture'] profile.save() registered = True else: print(user_form.errors, user_detail_form.errors) else: user_form = UserForm() user_detail_form = UserDetailForm() return render(request,'user/registration.html', {'user_form':user_form, 'user_detail_form':user_detail_form, 'registered':registered})
def update(request, id): user_list = User.object.get(id=id) form = UserForm(request.POST, instance=user_list) if form.is_valid(): form.save() return redirect('/show') return render(request, 'edit.html', {'user_list': user_list})
def signup(request): """ 계정생성 """ if request.method == "POST": updated_request = request.POST.copy() updated_request['email'] += '@konkuk.ac.kr' form = UserForm(updated_request) if form.is_valid(): form.save() user = User.objects.get( username=form.cleaned_data.get('username')) # 유저객체 받아오기 current_site = get_current_site(request) domain = current_site.domain uidb64 = urlsafe_base64_encode(force_bytes(user.pk)) token = jwt.encode({ 'user': user.id }, SECRET_KEY, algorithm='HS256').decode('utf-8') # 토큰 생성 message_data = signup_message(domain, uidb64, token) # 메세지 생성 mail_title = "BooKU 가입을 환영합니다! 이메일 인증을 완료해주세요!" mail_to = user.email email = EmailMessage(mail_title, message_data, from_email='*****@*****.**', to=[mail_to]) email.send() return render(request, 'user/email_auth_notice.html') else: form = UserForm() return render(request, 'user/signup.html', {'form': form})
def set_profile(request): '''修改个人资料''' user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) # 检查数据有效性 if not user_form.is_valid(): raise stat.UserFormErr(user_form.errors) if not profile_form.is_valid(): raise stat.ProfileFormErr(profile_form.errors) print('-----------------') print(user_form.cleaned_data) print(request.uid) # 保存数据 User.objects.filter(id=request.uid).update(**user_form.cleaned_data) Profile.objects.filter(id=request.uid).update(**profile_form.cleaned_data) # 删除旧的缓存 key = keys.PROFILE_K % request.uid model_user_key = 'Model-User-%s'%(request.uid) model_profile_key = 'Model-Profile-%s'%(request.uid) rds.delete(key) rds.delete(model_user_key) rds.delete(model_profile_key) #方法2 # user = User.objects.get(id=request.uid) # user.__dict__.update(user_form.cleaned_data) # user.save() return render_json()
def register(request): registered = False if request.method == 'POST': user_form = UserForm(data=request.POST) profile_form = UserProfileInfoForm(data=request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user if 'photos' in request.FILES: print('found it') profile.profile_pic = request.FILES['photos'] profile.save() registered = True messages.success(request, 'Registered!') else: print(user_form.errors,profile_form.errors) messages.warning(request, 'Username already taken.') return render(request,'login/registration1.html', {'registered':registered}) return redirect('/warehouse/') else: user_form = UserForm() profile_form = UserProfileInfoForm() return render(request,'login/registration1.html')
def user_add(request): errors = "" user_form = UserForm() if request.method == 'POST': user_form = UserForm(request.POST, request.FILES) csrf = Csrf.objects.get(session=request.session.session_key) if csrf.csrf != request.POST.get('csrfmiddlewaretoken'): csrf.csrf = request.POST.get('csrfmiddlewaretoken') csrf.save() password_p = re.compile(r"^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}") password = request.POST.get('password') if password_p.match(password): if user_form.is_valid(): user_form.save() user = User.objects.get(email=request.POST.get('email')) role = Role.objects.get(id=1) user.username = request.POST.get('last_name') user.is_active = True user.role = role user.set_password(request.POST['password']) user.save() tasks.send_user.delay(user, request.POST['password']) return redirect(request.path.replace('/add/', "/")) else: errors = user_form.errors else: errors = "密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间" return render(request, 'user_change.html', {'user_forms': user_form, 'errors': errors})
def register(request): if request.method == 'POST': uf = UserForm(request.POST, prefix='user') upf = MyUserForm(request.POST, prefix='userprofile') if uf.is_valid() * upf.is_valid(): user = User.objects.create_user(username=uf.cleaned_data['username'], password=uf.cleaned_data['password'], first_name=uf.cleaned_data['first_name'], last_name=uf.cleaned_data['last_name'], email=uf.cleaned_data['email']) user.is_active = False user.save() # userprofile = User.objects.get(id=user.id).myuser # userprofile = user.userprofile # except UserProfile.DoesNotExist, e: # userprofile = UserProfile(user=user) # userprofile.save() # userprofile = upf.save(commit=False) # userprofile.user = user userprofile = MyUser(user=user, phone_number=upf.cleaned_data['phone_number'], address=upf.cleaned_data['address']) # userprofile.user.id = request.user.id userprofile.save() return render(request, 'user/regOK.html') else: uf = UserForm(prefix='user') upf = MyUserForm(prefix='userprofile') return render(request, 'user/register.html', {'userform': uf, 'userprofileform': upf})
def CreateProfile(request): if request.method == 'POST': user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user profile.save() messages.add_message(request, messages.INFO, "Vous êtes désormais inscrit.") return redirect('/') else: user_form = UserForm() profile_form = ProfileForm() return render(request, 'registration/create.html', { 'user_form': user_form, 'profile_form': profile_form })
def update(request, id): user = User.objects.get(id=id) form = UserForm(request.POST, instance = user) if form.is_valid(): form.save() return redirect("/show") return render(request, 'edit.html', {'user': user})
def set_profile(request): '''修改用户信息,及用户配置''' user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) # 验证 user 表单的数据 if not user_form.is_valid(): raise stat.UserFormErr(user_form.errors) # 验证 profile 表单的数据 if not profile_form.is_valid(): raise stat.ProfileFormErr(profile_form.errors) # 修改用户数据 User.objects.filter(id=request.uid).update(**user_form.cleaned_data) # 修改 profile 数据 Profile.objects.update_or_create(id=request.uid, defaults=profile_form.cleaned_data) # 更新缓存 key = keys.MODEL_K % (Profile.__name__, request.uid) rds.delete(key) return render_json()
def set_profile(request): # 将提交的数据放进表单,并初始化 user_form = UserForm(request.POST) user = request.user # 判断表单是否有效 if user_form.is_valid(): # __dict__ 用来修改类对象的属性值 user.__dict__.update(user_form.cleaned_data) user.save() else: # 直接抛出实例,手动添加data raise status.UserDataErr(user_form.errors) # return render_json(data=user_form.errors, code=status.UserDataErr) profile_form = ProfileForm(request.POST) # profile = user.profile if profile_form.is_valid(): # 当你通过表单获取你的模型数据,但是需要给模型里null=False字段添加一些非表单的数据,该方法会非常有用。如果你指定commit=False, # 那么save方法不会理解将表单数据存储到数据库,而是给你返回一个当前对象。这时你可以添加表单以外的额外数据,再一起存储。 # 生成一个空对象,减少跟数据库通信的次数 profile = profile_form.save(commit=False) profile.id = user.id profile.save() # 缓存更新 key = keys.PROFILE_KEY % request.user.id # 通过删除缓存达到更新目的,还有就是被动的过期 # cache.delete(key) cache.set(key, profile.to_dict()) else: raise status.ProfileDataErr(profile_form.errors) # return render_json(data=profile_form.errors, code=status.ProfileDataErr) return render_json()
def put(self, request, *args, **kwargs): if request.content_type == 'text/plain;charset=UTF-8': data = json.loads(request.body.decode('utf-8')) else: data = request.data user = get_user_from_request(request) form = UserForm(data) if form.is_valid(): user.first_name = data.get('first_name') user.last_name = data.get('last_name') user.contact = data.get('vk') if data.get('image'): user_avatar = request.data.get('image') upload_path = 'avatar/{}.jpg'.format(user.id) upload_file(upload_path, user_avatar) user.avatar = MEDIA_URL + upload_path user_notification = get_object_or_404(UserSubscription, user=user) if data.get('notification') is not None: user_notification.email_notification = data.get('notification') user_notification.save() user.save() serializer = self.get_serializer(user) data = serializer.data return JsonResponse({ **{ 'notification': user_notification.email_notification }, **data }) else: return JsonResponse( {'detail': 'Ошибка создания, проверьте данные'}, status=400)
def post(self, request): account_form = AccountForm(request.POST) user_form = UserForm(request.POST) if account_form.is_valid() and user_form.is_valid(): # save user details, but don't add to database yet user = user_form.save(commit=False) # save username as email user.username = user.email # save account detail, but don't add to database account = account_form.save(commit=False) # add account to user user.account = account # save user to user database user.save() # Redirect to login page return redirect(reverse('login')) else: # Make new form account_form = AccountForm() user_form = UserForm() args = {'account_form': account_form, 'user_form': user_form} return render(request, self.template_name, args)
def set_profile(request): '''修改个人资料''' user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) # 检查 User 的数据 if not user_form.is_valid(): raise stat.UserDataErrr(user_form.errors) # 检查 Profile 的数据 if not profile_form.is_valid(): raise stat.ProfileDataErrr(profile_form.errors) user = request.user # 保存用户的数据 user.__dict__.update(user_form.cleaned_data) user.save() # 保存交友资料的数据 user.profile.__dict__.update(profile_form.cleaned_data) user.profile.save() # 修改缓存 key = keys.PROFILE_KEY % request.user.id rds.set(key, user.profile.to_dict()) return render_json()
def set_profile(request): '''修改个人资料''' user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) # 检查数据有效性 if not user_form.is_valid(): raise stat.UserFormErr(user_form.errors) if not profile_form.is_valid(): raise stat.ProfileFormErr(profile_form.errors) # 保存数据 User.objects.filter(id=request.uid).update(**user_form.cleaned_data) Profile.objects.filter(id=request.uid).update(**profile_form.cleaned_data) # 删除旧的缓存 key = keys.PROFILE_K % request.uid rds.delete(key) # 文强 + 程超 的思路 # user = User.objects.get(id=request.uid) # user.__dict__.update(user_form.cleaned_data) # user.save() return render_json()
def register(request): user_form = UserForm(request.POST or None) profile_form = ProfileForm(request.POST or None, request.FILES or None) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save(commit=False) try: validate_password(user_form.cleaned_data.get('password'), user) except ValidationError as e: user_form.add_error('password', e) return render(request, 'user/registration.html', context={ 'user_form': user_form, 'profile_form': profile_form, }) user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user profile.save() return render(request, 'user/registration.html', context={ 'user_form': user_form, 'profile_form': profile_form })
def update_user(request, pk): # try: # user = User.objects.get(pk=pk) # except User.DoesNotExist: # raise Http404 user = get_object_or_404(User, pk=pk) if request.method == 'POST': form = UserForm(request.POST, instance=user) if form.is_valid(): form.save() # return HttpResponseRedirect(reverse('users-name')) return redirect('users-name') elif request.method == 'GET': # instance == type(user) == User form = UserForm(instance=user) context = { 'user_form': form, 'user_instance': user, } return render( request, 'create_user.html', context=context, )
def register(request): #is registration successful registered = False if request.method == 'POST': user_form = UserForm(data=request.POST) profile_form = UserProfileForm(data=request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() #hash password user.set_password(user.password) user.save() # commit - we need to set the user attribute our selves profile = profile_form.save(commit=False) profile.user = user profile.save() registered = True else: print user_form.errors, profile_form.errors else: user_form = UserForm() profile_form = UserProfileForm() return render( request, 'user/register.html', { 'user_form': user_form, 'profile_form': profile_form, 'registered': registered })
def register(request): registered = False if request.method == 'POST': user_form = UserForm(data=request.POST) profile_form = UserProfileInfoForm(data=request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() profile = profile_form.save(commit=False) profile.user = user if 'profile_pic' in request.FILES: print('found it') profile.save() registered = True else: print(user_form.errors, profile_form.errors) else: user_form = UserForm() profile_form = UserProfileInfoForm() return render( request, 'user/registration.html', { 'user_form': user_form, 'profile_form': profile_form, 'registered': registered })
def update(request): '''修改资料''' # 从request.POST 里面得到一个类字典的对象 user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) # 如果两个提交的信息都没有问题的话: if user_form.is_valid() and profile_form.is_valid(): uid = request.session['uid'] # update `user` set nickname = 'xxx' ... where id = 123; # UserForm.cleaned_data 是更新的数据, 并且需要进行拆包, 因为这个是一个字典 User.objects.filter(id=uid).update(**user_form.cleaned_data) # 先更新, 如果没有数据可供更新的话, 创建一个新的并将 default 作为默认的写进去 Profile.objects.update_or_create(id=uid, defaults=profile_form.cleaned_data) return render_json() # 如果有异常的话: else: # 错误信息是用字典来标记的 err = {} err.update(user_form.errors) err.update(profile_form.errors) # return render_json(err, stat.ProfileErr) raise stat.ProfileErr(err)
def validation_and_work_with_info(request, registered): ''' General work with User info and return a context for templates ''' if request.method == 'POST': user_form = UserForm(data=request.POST) profile_form = UserProfileInfoForm(request.POST, request.FILES) if user_form.is_valid() and profile_form.is_valid(): work_with_info_after_true_validation(request, user_form, profile_form, registered) else: print(user_form.errors, profile_form.errors) return HttpResponse(user_form.errors, profile_form.errors) else: user_form = UserForm() profile_form = UserProfileInfoForm() context = { 'user_form': user_form, 'profile_form': profile_form, 'registered': registered, } return context
def register(request): registered = False if request.method == "POST": user_form = UserForm(data=request.POST) if user_form.is_valid(): user = user_form.save() user.password = make_password(request.POST.get('password')) user.save() url = base_url + "/api/v2/users/" payload = json.dumps( {"user_id": request.POST.get('enrollment_id')}) headers = { 'Authorization': token, 'Content-Type': "application/json", 'cache-control': "no-cache", } response = requests.request("POST", url, data=payload, headers=headers) print(response.status_code) print(response.text) registered = True messages.add_message( request, messages.INFO, 'Registration completed. Login to continue...') return HttpResponseRedirect(reverse('user:login')) else: print(user_form.errors) message = None if 'Enrollment' in str(user_form.errors): message = 'User already exists with this Enrollment Id' else: message = 'User already exists with this Email' if 'Enrollment' in str(user_form.errors) and 'Email' in str( user_form.errors): message = 'User already exists with this Enrollment Id and Email' messages.add_message(request, messages.INFO, message) return HttpResponseRedirect(reverse('user:register')) if 'enrollment_id' in request.session: return HttpResponseRedirect(reverse('user:index')) message = None for msg in messages.get_messages(request): message = msg break return render(request, 'user/register.html', { 'registered': registered, 'message': message })
def test_user_without_first_name_is_not_valid(self): form = UserForm(data={ 'username' : 'Korisnik', 'last_name' : 'OvoJePrezime', 'password' : 'Sifra1234567!', 'email' : '*****@*****.**' }) self.assertFalse(form.is_valid())
def edition(request, id): user = User.objects.get(id=id) form = UserForm(instance=user) if request.method == "POST": form = UserForm(request.POST, instance=user) if form.is_valid(): User.objects.filter(id=user.id).update(email=user.email) context = {'id': user.id, 'email': user.email, 'form': form} return render(request, 'edition.html', context)
def register(request): if request.method == "POST": form = UserForm(request.POST) if form.is_valid(): form.save() form = UserForm() else: form = UserForm() return render(request, 'registration/register.html', {'form': form})
def test_user_form_is_valid(self): form = UserForm(data={ 'username' : 'Korisnik', 'first_name' : 'OvoJeIme', 'last_name' : 'OvoJePrezime', 'password' : 'Sifra1234567!', 'email' : '*****@*****.**' }) self.assertTrue(form.is_valid())
def new_user(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): #user_ = User.objects.create() form.save()#for_user=user_) return HttpResponseRedirect('/profile/') else: form = UserForm() return render(request, 'new_user.html', {'form' : form})
def register(request): template = 'user/register.html' if request.method=='GET': return render(request, template, {'userForm':UserForm(), 'userProfileForm':UserProfileForm()}) # request.method == 'POST': userForm = UserForm(request.POST) userProfileForm = UserProfileForm(request.POST) if not (userForm.is_valid() and userProfileForm.is_valid()): return render(request, template, {'userForm':userForm, 'userProfileForm':userProfileForm}) user = userForm.save() user.set_password(user.password) user.save() userProfile = userProfileForm.save(commit=False) userProfile.user = user userProfile.save() messages.success(request, '歡迎註冊') return redirect(reverse('main:main'))
def register(request): if request.method == "POST": rst = json.loads(request.body.decode("utf-8")) uf = UserForm(rst) if uf.is_valid(): #检测用户是否存在 checkUser = User.objects.filter(email__exact = uf.cleaned_data['email']).first() if checkUser: data = {"status" : 'error', 'msg' : "此Email账户已存在" } return HttpResponse(json.dumps(data), content_type="application/json") user = User() user.username = uf.cleaned_data['username'] pwd = (uf.cleaned_data['password'] + keyPwd).encode("utf-8") user.password = hashlib.sha1(pwd).hexdigest() user.qq = uf.cleaned_data['qq'] user.email = uf.cleaned_data['email'] user.random = ''.join(random.sample(string.ascii_letters + string.digits, 10)) user.save() data = {"status" : 'success', 'msg' : "" } return HttpResponse(json.dumps(data), content_type="application/json") else: data = {"status" : 'error', 'msg' : "Illegal post" } return HttpResponse(json.dumps(data), content_type="application/json") else: data = {"status" : 'error', 'msg' : "Only post method" } return HttpResponse(json.dumps(data), content_type="application/json")
def register(request): if request.method == 'POST': user_form = UserForm(request.POST) userinformation_form = UserInformationForm(request.POST) studentinformation_form = StudentInformationForm(request.POST) if ( user_form.is_valid() and userinformation_form.is_valid() and (studentinformation_form.is_valid() or (not studentinformation_form.cleaned_data.get('faculty') and not studentinformation_form.cleaned_data.get('s_number')))): created_user = user_form.save(commit=False) created_user.is_active = False created_user.save() acc = [] if (studentinformation_form.cleaned_data.get('faculty') and studentinformation_form.cleaned_data.get('s_number')): created_student_information = studentinformation_form.save(commit=False) created_student_information.user = created_user created_student_information.save() zih_mail = created_student_information.make_zih_mail() verification_mail(created_user, 'student', zih_mail, request) acc.append(zih_mail) else: created_user_information = userinformation_form.save(commit=False) created_user_information.user = created_user created_user_information.save() verification_mail(created_user, 'email', created_user.email, request) acc.append(created_user.email) return render( request, 'registration/success.html', { 'title': _('Registration successfull'), 'acc': acc } ) else: print('validation failed') else: user_form = UserForm() userinformation_form = UserInformationForm() studentinformation_form = StudentInformationForm() return render( request, 'registration/register.html', { 'title': _('Registration'), 'user_form': user_form, 'userinformation_form': userinformation_form, 'studentinformation_form': studentinformation_form } )