def registration(request): if request.POST: form = RegistrationForm(request.POST) if form.is_valid(): new_user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password']) new_user.is_active = True new_user.save() user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password']) auth.login(request, user) profile = Profile(user=new_user, nick=form.cleaned_data['username']) profile.save() send_registration_letter(profile) Subscription.add(email=form.cleaned_data['email'], auto_confirm=True) return HttpResponseRedirect('/') else: form = RegistrationForm(initial={}) return render_to_response(request, 'registration.html', {'form': form})
def registration(request): if request.POST: form = RegistrationForm(request.POST) if form.is_valid(): new_user = User.objects.create_user( form.cleaned_data["name"], form.cleaned_data["email"], form.cleaned_data["password"] ) new_user.is_active = True new_user.save() user = authenticate(username=form.cleaned_data["name"], password=form.cleaned_data["password"]) auth.login(request, user) profile = Profile(user=new_user, nick=form.cleaned_data["name"]) profile.save() send_registration_letter(profile) Subscription.add(email=form.cleaned_data["email"]) return HttpResponseRedirect("/") else: form = RegistrationForm(initial={}) return render_to_response(request, "registration.html", {"form": form})