def test_UserForm_invalid(self): form = UserForm(data={ "username": '', "first_name": '', "last_name": 'testlname' }) self.assertFalse(form.is_valid())
def test_UserForm_valid(self): form = UserForm( data={ "username": '******', "first_name": 'testname', "last_name": 'testlname' }) self.assertTrue(form.is_valid())
def update_profile(request): if request.method == 'POST': user_form = UserForm(request.POST, instance=request.user) if user_form.is_valid(): user_form.save() return redirect('profile') else: user_form = UserForm(instance=request.user) return render(request, 'update_profile.html', {'user_form': user_form})
def create_user(request): if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): # email = form.cleaned_data['email'] # subject = 'FirstPick account created' # message = 'Welcome to FirstPick, go shopping online now!!!!' # sender = '*****@*****.**' # send_mail(subject, message,sender,[email]) form.save() return HttpResponseRedirect('/') else: form = UserForm() return render(request, 'create_user.html', {'forms': form})