def register request if request method POST form RegistrationForm requ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def register(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
user = request['user']
password = request['password']
email = request['email']
jabber = request['jabber']
a = User(username=user,first_name='',last_name='',email=email,password=password,is_staff=0,is_active=1,is_superuser=0,last_login=datetime.datetime.today(),date_joined=datetime.datetime.today())
a.save()
b = User.objects.get(username=user)
b.set_password(password)
b.save()
c = City.objects.get(pk=1)
Profile(user=b,city=c,jabber=jabber,website='http://django.com').save()
return HttpResponseRedirect('/profile/')
else:
if request.user.is_anonymous():
form = RegistrationForm()
return render_to_response('registration/registration.html',{'form':form})
else:
return HttpResponseRedirect('/profile/')