1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00

Changed slightly misleading example in docs/sessions.txt to use baggage-less 'members' instead of 'users'

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1211 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-11-13 04:43:07 +00:00
parent 23c9e2aec9
commit 46083845d4

View File

@ -92,21 +92,21 @@ posts a comment. It doesn't let a user post a comment more than once::
request.session['has_commented'] = True request.session['has_commented'] = True
return HttpResponse('Thanks for your comment!') return HttpResponse('Thanks for your comment!')
This simplistic view logs a user in:: This simplistic view logs in a "member" of the site::
def login(request): def login(request):
u = users.get_object(username__exact=request.POST['username']) m = members.get_object(username__exact=request.POST['username'])
if u.check_password(request.POST['password']): if m.password == request.POST['password']:
request.session['user_id'] = u.id request.session['member_id'] = m.id
return HttpResponse("You're logged in.") return HttpResponse("You're logged in.")
else: else:
return HttpResponse("Your username and password didn't match.") return HttpResponse("Your username and password didn't match.")
...And this one logs a user out, according to ``login()`` above:: ...And this one logs a member out, according to ``login()`` above::
def logout(request): def logout(request):
try: try:
del request.session['user_id'] del request.session['member_id']
except KeyError: except KeyError:
pass pass
return HttpResponse("You're logged out.") return HttpResponse("You're logged out.")