for the login I do (username must be the id field(pk) of an 'owners' table
and password is a field of the same table):
def login_user(request):
c = {}
c.update(csrf(request))
state = ""
if request.POST:
password = request.POST.get('password')
id = request.POST.get('id')
try:
user = Owners.objects.get(id = id)
if user:
if user.simple_check_password(password):
url = reverse('main', kwargs={ 'user_id': user.id })
return HttpResponseRedirect(url)
else:
state = 'Incorrect username or password'
else:
state = 'Incorrect username or password'
except Exception as e:
state = 'Incorrect username or password'
print state
return render_to_response('index.html', locals(), context_instance=
RequestContext(request))
and I also define:
def set_password(self, raw_password):
self.password = make_password(raw_password)
def check_password(self, raw_password):
"""
Returns a boolean of whether the raw_password was correct. Handles
hashing formats behind the scenes.
"""
def setter(raw_password):
self.set_password(raw_password)
self.save()
return check_password(raw_password, self.password, setter=None)
def simple_check_password(self,raw_password):
return raw_password == self.password
and at least it seems to me that it works, I mean the user logs in to the
main.html page.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/oPmX_2NBchQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.