Re: "Authenticating Users" where should I put the code?

2014-03-06 Thread Jack Yan
Thank you :)

On Friday, March 7, 2014 12:13:26 AM UTC+8, Felipe Coelho wrote:
>
> 2014-03-06 11:45 GMT-03:00 Jack Yan >:
>
>> in the tutorial and section "Authenticating Users":
>> https://docs.djangoproject.com/en/1.6/topics/auth/default/
>>
>> where can I put code:
>>
>> from django.contrib.auth import authenticateuser = 
>> authenticate(username='john', password='secret')if user is not None:
>> # the password verified for the user
>> if user.is_active:
>> print("User is valid, active and authenticated")
>> else:
>> print("The password is valid, but the account has been 
>> disabled!")else:
>> # the authentication system was unable to verify the username and 
>> password
>> print("The username and password were incorrect.")
>>
>> in what file or what folder?
>>
>
> That is described later in the same page [1].
>
> But if you just want to enable login/logout/password reset for your 
> project, the easiest way is to include Django's default auth views in your 
> urls.py [2].
>
> [1] 
> https://docs.djangoproject.com/en/1.6/topics/auth/default/#how-to-log-a-user-in
> [2] 
> https://docs.djangoproject.com/en/1.6/topics/auth/default/#module-django.contrib.auth.views
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ee3a12da-814c-4169-bc59-d160176566a9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: "Authenticating Users" where should I put the code?

2014-03-06 Thread Felipe Bessa Coelho
2014-03-06 11:45 GMT-03:00 Jack Yan :

> in the tutorial and section "Authenticating Users":
> https://docs.djangoproject.com/en/1.6/topics/auth/default/
>
> where can I put code:
>
> from django.contrib.auth import authenticateuser = 
> authenticate(username='john', password='secret')if user is not None:
> # the password verified for the user
> if user.is_active:
> print("User is valid, active and authenticated")
> else:
> print("The password is valid, but the account has been 
> disabled!")else:
> # the authentication system was unable to verify the username and password
> print("The username and password were incorrect.")
>
> in what file or what folder?
>

That is described later in the same page [1].

But if you just want to enable login/logout/password reset for your
project, the easiest way is to include Django's default auth views in your
urls.py [2].

[1]
https://docs.djangoproject.com/en/1.6/topics/auth/default/#how-to-log-a-user-in
[2]
https://docs.djangoproject.com/en/1.6/topics/auth/default/#module-django.contrib.auth.views

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5dYfNxCPTL%2BcqK%3DHaQBhKPYQSZ-BMqKnHk7vu-vJuqg84K2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: "Authenticating Users" where should I put the code?

2014-03-06 Thread Robin Lery
This should be in your views.py.


On Thu, Mar 6, 2014 at 8:15 PM, Jack Yan  wrote:

> in the tutorial and section "Authenticating Users":
> https://docs.djangoproject.com/en/1.6/topics/auth/default/
>
> where can I put code:
>
> from django.contrib.auth import authenticateuser = 
> authenticate(username='john', password='secret')if user is not None:
> # the password verified for the user
> if user.is_active:
> print("User is valid, active and authenticated")
> else:
> print("The password is valid, but the account has been 
> disabled!")else:
> # the authentication system was unable to verify the username and password
> print("The username and password were incorrect.")
>
> in what file or what folder?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0654812d-74d5-48a1-a977-26958f417a61%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B4-nGoLSsJTSL5GmnGBgmij1dYD-44CLjv0zeVw9soqJR6JyA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


"Authenticating Users" where should I put the code?

2014-03-06 Thread Jack Yan
in the tutorial and section "Authenticating Users":
https://docs.djangoproject.com/en/1.6/topics/auth/default/

where can I put code:

from django.contrib.auth import authenticateuser = 
authenticate(username='john', password='secret')if user is not None:
# the password verified for the user
if user.is_active:
print("User is valid, active and authenticated")
else:
print("The password is valid, but the account has been disabled!")else:
# the authentication system was unable to verify the username and password
print("The username and password were incorrect.")

in what file or what folder?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0654812d-74d5-48a1-a977-26958f417a61%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.