Example #1
0
def register(request):
    context = RequestContext(request)
    username = request.POST['username']
    password = request.POST['password1']
    if request.method == 'POST':
    	form = UserForm(data=request.POST)
        critic_form = CriticForm()
        if form.is_valid():
            user = form.save()
            #user.set_password(user.password)
            user.save()

            critic = critic_form.save(commit=False)

            critic.user = user
            critic.image = '/static/img/profile.jpg'
            critic.save()
            user2 = authenticate(username=username, password=password)        
            if user2 is not None:
                if user.is_active:
                    auth_login(request, user2)
                    return HttpResponseRedirect('/feed')
                else:
                    pass
            else:
                return HttpResponseRedirect('/')
        else:
            return HttpResponseRedirect('/')
    else:
        form = UserForm()
        return HttpResponseRedirect('/')