Example #1
0
def signup(request):
  if request.method == 'POST':
    form = EmailUserCreationForm(request.POST)
    if form.is_valid():
      message = None

      email = form.clean_email()
      password = form.clean_password2()
      form.save()

      user = authenticate(email=email, password=password)
      if (user is not None) and (user.is_active):
        login(request, user)
        message = "Registration successful"
      else:
        message = "There was an error automatically logging you in. Try <a href=\"/index/\">logging in</a> manually."

      # Since user does not have any accounts by the time they signe in,
      # we should redirect them to accounts page instead of feed page.
      return redirect('/feed/')

  else:
    form = EmailUserCreationForm()

  return render(request, 'signup.html', {'form': form})
Example #2
0
def signup(request):
    if request.method == 'POST':
        form = EmailUserCreationForm(request.POST)
        if form.is_valid():
            message = None

            email = form.clean_email()
            password = form.clean_password2()
            form.save()

            user = authenticate(email=email, password=password)
            if (user is not None) and (user.is_active):
                login(request, user)
                message = "Registration successful"
            else:
                message = "There was an error automatically logging you in. Try <a href=\"/index/\">logging in</a> manually."

            # Since user does not have any accounts by the time they signe in,
            # we should redirect them to accounts page instead of feed page.
            return redirect('/feed/')

    else:
        form = EmailUserCreationForm()

    return render(request, 'signup.html', {'form': form})
Example #3
0
def register(request):
	if request.method == 'POST':
		form = EmailUserCreationForm(request.POST)
		if form.is_valid():
			new_user = form.save()
			return HttpResponseRedirect("/polls/")
	else:
		form = UserCreationForm()
	return render_to_response("registration/register.html", {
		'form': form,},
		context_instance=RequestContext(request)
		)