On 3/11/06, layik <[EMAIL PROTECTED]> wrote: > > I am happy to tell anyone who is trying to do the same mistake I was > doing for the past day probably!! that, forms are loaded empty for > something to be put in them and then PROCESSED accordingly. > > I was trying to LOAD and PROCESS the form together. so the order is: > direct browser to LOAD the login_form, THEN in the ACTION direct the > browser to PROCESS the form. > > > BUT now I have another problem... > > why i cannot sign anyone in? i hav created users who are NOT staff and > users who are staff and a superuser as well. using the code I had > mentioned early with my development server should I be able to sign in? > > in my view I have these: first to load the log in form, i direct the > browser here => > #clean up and test cookies > def login(request): > if request.POST: > if request.session.test_cookie_worked(): > request.session.delete_test_cookie() > return HttpResponse("You're logged in.") > else: > return HttpResponse("Please enable cookies and try again.") > request.session.set_test_cookie() > return render_to_response('claims/login_form') > > THEN TO PROCESS THE FORM => > def dologin(request): > m = users.get_object( username__exact = request.POST['username'] ) > if m.password == request.POST['password']: > request.session['user_id'] = m.id > return HttpResponse("You're logged in.") > else: > return HttpResponse("Your username and password didn't match.") > > > I ALWAYS get the didnt match response! > > any clues???? > > many thanks
maybe you should: from django.contrib.auth.models import SESSION_KEY if user.check_password(request.POST.get('password', '')): request.session[SESSION_KEY] = user.id #<-------------this line user.last_login = datetime.datetime.now() user.save() -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---