Created
October 8, 2012 18:31
-
-
Save Aaron1011/3854085 to your computer and use it in GitHub Desktop.
Texting wall views
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
# Create your views here. | |
from django.shortcuts import render_to_response | |
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm | |
from django import forms | |
from django.contrib.auth import forms | |
from django.core.context_processors import csrf | |
from django.contrib.auth.models import User | |
from django.template import RequestContext | |
from django.contrib.auth import authenticate | |
from django.contrib.auth import login as auth_login | |
from django.http import HttpResponse | |
my_choice = ( | |
('BG', 'Blog'), | |
('FR', 'Friend'), | |
('OT', 'Other',) | |
) | |
class UserCreation(UserCreationForm): | |
about_textwall = forms.ChoiceField(my_choice) | |
class WallForm(forms.ModelForm): | |
class Meta: | |
model = Wall | |
def create_account(request): | |
form = UserCreation() | |
if request.POST: | |
form = UserCreationForm(data=request.POST) | |
if form.is_valid(): | |
print form.cleaned_data["username"] | |
form.clean_username() | |
form.clean_password2() | |
form.save() | |
user = authenticate(username=form.cleaned_data["username"], | |
password=form.cleaned_data["password1"]) | |
login(request,user) | |
return render_to_response('finish.html') | |
else: | |
return render_to_response( | |
"create_account.html", | |
{ "form": form }, RequestContext(request)) | |
def finish(request): | |
return HttpResponse("Login Successfull!") | |
def new_wall(request): | |
if request.POST: | |
pass | |
else: | |
form = WallForm() | |
return render_to_response( | |
"create_wall.html", | |
{"form": form}, RequestContext(request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment