Django Multiple User Login

1,566 views
Skip to first unread message

Aakash Tewari

unread,
Feb 11, 2016, 7:30:21 AM2/11/16
to Django users
Hello


Here is new one I guess.

We have 3 types of users say A, B, C. All have 3 different login pages on same domain. We have extended User model by OneToOne relationship like this
class AModel(models.Model):
users = models.OneToOneField(User, on_delete=models.CASCADE)
is_A = models.NullBooleanField(default=False)

class BModel(models.Model):
users = models.OneToOneField(User, on_delete=models.CASCADE)
is_B = models.NullBooleanField(default=False)

class BModel(models.Model):
users = models.OneToOneField(User, on_delete=models.CASCADE)
is_B = models.NullBooleanField(default=False)


Now During login we check like this :

username=request.POST.get('username','')
password=request.POST.get('pass','')
user = authenticate(username=username, password=password)
u = AModel.objects.get(users=user)
if user is not None:
if user.is_active and u.isA:
login(request, user)
return HttpResponseRedirect("/home/")

same way for B and C



Now issue is when A login session is set and everything works fine, but when user B logins, session for user A is removed.

How can we allow 3 user 3 tabs 3 diff(login and home page) on same browser


Thanks

jorr...@gmail.com

unread,
Feb 11, 2016, 9:49:19 AM2/11/16
to Django users
I'm just being curious here but in what scenario would you have multiple people logging in at the same time using the same computer/browser?

Andreas Kuhne

unread,
Feb 11, 2016, 10:34:54 AM2/11/16
to django...@googlegroups.com
You can't?

Not without logging out the previous user. 

The session itself is used to contain a reference to the current user. You can only have one session to a certain domain (for example www.example.com and app.example.com are 2 different domains). The only way for the other user to login is to create a new sesison (and invalidating the old one).

Regards,

Andréas

--
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...@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/5b9ed0bd-0e32-4239-8ebd-ab6275f82680%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Avraham Serour

unread,
Feb 11, 2016, 10:43:37 AM2/11/16
to django-users
maybe you can create your own session model that is related to multiple users

Reply all
Reply to author
Forward
0 new messages