when I try to log in i get an error that says
duplicate key value violates unique constraint "auth_user_username_key"
DETAIL: Key (username)=(mrfrasha) already exists.
I really don’t have any idea what this means at all. It seems weird. this seems like an error you would get it you were trying to create a username that was already in use but i merely trying to log in.
<form action="" method="POST">
Username: <input type="text" name="username" />
Password: <input type="text" name="password" />
<input type = "submit" value = "Login"/>< br />
def login(request):
if request.POST=='POST':
username = request.POST['username']
password =request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return render_to_response('profile.html')
else:
print "Your account has been disabled!"#come back to me
else:
sentence = "Your username and password were incorrect."# come back to me
return render_to_response('login.html', {'sentence':sentence})
else:
return render_to_response('login.html')#come back to me
The problem which i think is that you have override the django
loginfunction by declaring the function of same name which then becomes recursive when this statement will executelogin(request, user).As your function takes only one parameter that is why
login(request, user)this statement cause exceptions thatlogin() takes one argument and got two.Change your function name to some other e.g. my_login(request)
Hope this helps.
Thanks
EDITED
Your function should be like this.