def newUser(request): if request.method == 'POST': form = NewUserForm(request.POST) if form.is_valid(): form.save() return redirect('/account/home') else: form = NewUserForm() args = {'form': form} return render(request, 'account/new-user.html', args)
def test_NewUserForm_save(register_valid_post_request, db_w_group): from account.forms import NewUserForm from account.templatetags import user_utils request = register_valid_post_request form = NewUserForm(request.POST) form.save() user = User.objects.get(pk=1) assert user.username == request.POST.get('username') assert user.email == request.POST.get('email') assert user_utils.has_group(user, 'basic_web_user') assert user_utils.has_permission(user, 'do stuff')
def new(request): if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): new_user = form.save() return HttpResponseRedirect("./") else: form = NewUserForm() return render_to_response("account/new.html", {"form": form,}, context_instance=RequestContext(request))
def new(request): if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): new_user = form.save() return HttpResponseRedirect("./") else: form = NewUserForm() return render_to_response("account/new.html", { "form": form, }, context_instance=RequestContext(request))
def registerPage(request): if request.method == "POST": form = NewUserForm(request.POST) if form.is_valid(): user = form.save() login(request, user) messages.success(request, "Registration successful.") return redirect("index") messages.error(request, "Unsuccessful registration. Invalid information.") form = NewUserForm return render(request=request, template_name="register.html", context={"form": form})