My views.py is below
def register(request):
if request.GET.get('name')and request.GET.get('surname')and request.GET.get('username') and request.GET.get('userpassword') and request.GET.get('repassword') and request.GET.get('email'):
name= request.GET.get('name')
surname= request.GET.get('surname')
username = request.GET.get('username')
userpassword = request.GET.get('userpassword')
repassword = request.GET.get('repassword')
email = request.GET.get('email')
if name=="enter name"or surname=="enter surname"or username== "enter username" or userpassword=="pass" or repassword=="pass" or email=="enter mail":
return render_to_response('hata.html')
if userpassword!=repassword:
return render_to_response('hata1.html')
if userpassword == repassword:
User.objects.create_user(username=username, password=userpassword, email=email)
User.first_name = name
User.last_name = surname
User.save()
return HttpResponseRedirect('/login/')
I simpy try to add name and surname to the db during the reqistration process; however, when I run the server and make a registration, error occurs.
unbound method save() must be called with User instance as first argument (got nothing instead)
How can I fixed that? I will be really appreciated if you have any solution
As Devict mentioned, I did the neccessary changes in the code;however, I can not make the registered user log-in now. My log-in code is below
def login(request):
c = {}
if request.method == 'POST':
username = request.POST['username']
userpassword = request.POST['userpassword']
username = authenticate(username=username, password=userpassword)
if username is not None:
if username.is_active:
auth.login(request, username)
return HttpResponseRedirect('/')
return render_to_response('login.html', c, context_instance=RequestContext(request) )