How to create two different login system

27 views
Skip to first unread message

maunish dave

unread,
Dec 14, 2018, 1:28:50 AM12/14/18
to django...@googlegroups.com
My project contains two user one for managers and other for employees any suggestions?

Mike Dewhirst

unread,
Dec 14, 2018, 2:09:20 AM12/14/18
to django...@googlegroups.com
On 14/12/2018 5:28 PM, maunish dave wrote:
> My project contains two user one for managers and other for employees
> any suggestions?

Django contrib.auth already has groups and I use them for deciding what
they can see vertically. Horizontally I use the ordinary relational
mewchanisms.

Here is part of my utils.py for groups ... where 'name' is the group
name ...



# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
def is_author(user, name='author'):
return is_member(user, name)

def is_authority(user, name='authority'):
return is_member(user, name)

def is_consumer(user, name='consumer'):
return is_member(user, name)

def is_editor(user, name='editor'):
return is_member(user, name)

def is_manager(user, name='manager'):
return is_member(user, name)

def is_useredit(user, name='useredit'):
return is_member(user, name)
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
def is_member(user, name):
return user.is_superuser or user.groups.filter(name=name).exists()
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #





> --
> 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
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto: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/CALpJ3uJ%2BOu-tiv2beHU06ZN-6PhWDAqsivDvgvKZ_RUSXDFtUQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALpJ3uJ%2BOu-tiv2beHU06ZN-6PhWDAqsivDvgvKZ_RUSXDFtUQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Manjunath

unread,
Dec 14, 2018, 2:19:52 AM12/14/18
to Django users
There are multiple options to maintain different kind of users in Django.

When I came across this situation, I created a custom User class by inheriting AbstractBaseUser class and kept a positive integer field to maintain the type of user. Then I created Sub-classes Manager & Employee classes.
I created a custom authentication backend which will return the user object according to the user type.

You can try this or You can just extend the AbstractUser class.

maunish dave

unread,
Dec 14, 2018, 4:42:15 AM12/14/18
to django...@googlegroups.com
What if a normal user creates an account for manager instead of creating account for manager how to stop a normal user from creating a manager account?

--
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.
Reply all
Reply to author
Forward
0 new messages