Djnago User login

41 views
Skip to first unread message

Hossein Torabi

unread,
Mar 1, 2017, 2:43:33 PM3/1/17
to Django users
is there any method that i have two kind of users that once log in with user name and password and other one login with just with user name?

Constantine Covtushenko

unread,
Mar 1, 2017, 3:50:22 PM3/1/17
to django...@googlegroups.com
Hi Hossein,

I am not sure that understood you correctly.

Are you asking about the way how to handle two types of authentication?
One by user name and password,
an other by just username?


On Wed, Mar 1, 2017 at 4:05 PM, Hossein Torabi <ho3e...@gmail.com> wrote:
is there any method that i have two kind of users that once log in with user name and password and other one login with just with user name?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a4d0763b-0a0f-46c7-a75a-bd7f15ca7761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shawn Milochik

unread,
Mar 1, 2017, 5:07:02 PM3/1/17
to django...@googlegroups.com
It takes a little fiddling, but you can log in a user however you want.


In short, you can call django.contrib.auth.login(request, user) and force a login without any authentication if you really wanted to. Given that, you can make your own auth backend (subclass the default one) that returns True for certain usernames without checking the value of the password field.


Constantine Covtushenko

unread,
Mar 2, 2017, 12:09:03 AM3/2/17
to django...@googlegroups.com
+1 for CustomAuth Backend solution.

In runtime Django checks all set backends in the order so I would suggest to put your backend at the beginning of backend's list.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages