Created
July 25, 2011 20:18
-
-
Save pydanny/1105082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.auth import authenticate, login | |
| def signup(request, template_name="accounts/signup.html"): | |
| form = SignupForm(request.POST or None) | |
| if form.is_valid(): | |
| user = User.objects.create_user( | |
| username=request.POST.get('username'), | |
| first_name=request.POST.get('first_name'), | |
| last_name=request.POST.get('last_name'), | |
| #... (password, email, etc) | |
| ) | |
| user.save() | |
| user = authenticate(username=username, password=password) | |
| if user is not None and user.is_active: | |
| profile = Profile.object.create( | |
| user=user, | |
| ... (profile sutff here) | |
| ) | |
| login(request, user) | |
| return HttpResponseRedirect(reverse("signup_complete")) | |
| else: | |
| # go to page saying they suck or soemthing | |
| return render_to_response(template_name, { | |
| "form": form, | |
| }, | |
| context_instance=RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment