Hi Kushal,

Since the out-of-the box User model is coming from the auth module, you
can hardly extend this class. To store additional information for
different types of Users, you could create a custom UserProfile model,
which has a Foreign Key to the User model:


from django.db import models
...

class UserProfile(models.Model):
    class Meta:
        verbose_name_plural = "User Profiles"

    user = models.ForeignKey(User, related_name='user_profile', unique=True)
    user_type = models.CharField(max_length=1, choices=USER_TYPE,
default='h')

You could also write your own custom User Model with a user type field
and use that one instead of the built-in one:

https://docs.djangoproject.com/en/2.1/topics/auth/customizing/#substituting-a-custom-user-model


But what you describe almost sounds like you want to make use of the
permissions and groups, which are built into the django admin interface
as well, so I would read through this:

https://docs.djangoproject.com/en/3.0/topics/auth/default/#permissions-and-authorization


Antje

On 3/5/20 8:19 AM, Kushal Neupane wrote:
> I am trying to build a resturant management system. I made a super
> user. Now, i am trying to make cashier and finance users which must be
> assign by the super admin. Can i do it?
> -- 
> 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
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/59fed919-bf3b-40aa-8cd8-00f6cf7335a9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/59fed919-bf3b-40aa-8cd8-00f6cf7335a9%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/31516228-9acd-5037-006e-56674405f582%40gmail.com.
  • Custom User Kushal Neupane
    • Re: Custom User Antje Kazimiers

Reply via email to