moldels.py <https://drive.google.com/file/d/1nIwEzhn1R24MDPFFEz-QenzbUxBQV4as/view?usp=drive_web>
On Sun, Jul 7, 2019 at 9:33 AM laya Mahmoudi <[email protected]> wrote: > You should add some code in your settings.py like AUTH_USER_MODEL= > 'appname.modelname' which inherits django user mode. > > > در تاریخ یکشنبه ۷ ژوئیهٔ ۲۰۱۹، ۳:۳۷ Shazia Nusrat <[email protected]> > نوشت: > >> Hi All, >> I am having hard time to get multiple roles for users in a project and I >> am having errors. >> I've added related_name but still getting error. Can please tell me how >> to fix this? >> >> ******************************************* >> from django.db import models >> from django.contrib.auth.models import AbstractUser >> # Create your models here. >> >> class Role(models.Model): >> STUDENT = 1 >> TEACHER = 2 >> SECRETARY = 3 >> SUPERVISOR = 4 >> ADMIN = 5 >> ROLE_CHOICES = ( >> (STUDENT, 'student'), >> (TEACHER, 'teacher'), >> (SECRETARY, 'secretary'), >> (SUPERVISOR, 'supervisor'), >> (ADMIN, 'admin'), >> ) >> id = models.PositiveSmallIntegerField(choices=ROLE_CHOICES, >> primary_key=True) >> def __str__(self): >> return self.get_id_display() >> class User(AbstractUser): >> roles = models.ManyToManyField(Role) >> ******************************************************* >> >> I am getting error below: >> >> ******************************************************* >> ERRORS: >> auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' >> clashes with reverse accessor for 'User.groups'. >> HINT: Add or change a related_name argument to the definition for >> 'User.groups' or 'User.groups'. >> auth.User.user_permissions: (fields.E304) Reverse accessor for >> 'User.user_permissions' clashes with reverse accessor for >> 'User.user_permissions'. >> HINT: Add or change a related_name argument to the definition for >> 'User.user_permissions' or 'User.user_permissions'. >> users.User.groups: (fields.E304) Reverse accessor for 'User.groups' >> clashes with reverse accessor for 'User.groups'. >> HINT: Add or change a related_name argument to the definition for >> 'User.groups' or 'User.groups'. >> users.User.user_permissions: (fields.E304) Reverse accessor for >> 'User.user_permissions' clashes with reverse accessor for >> 'User.user_permissions'. >> HINT: Add or change a related_name argument to the definition for >> 'User.user_permissions' or 'User.user_permissions'. >> >> *********************************************************** >> >> Looking forward for your kind help. >> >> Thanks, >> >> Shazia >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> 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/CAD83tOyrfzvb3JCrgUFPUqTpxiaf-qLvy50nhgOLgA%2BpsjbURQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAD83tOyrfzvb3JCrgUFPUqTpxiaf-qLvy50nhgOLgA%2BpsjbURQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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/CABL_bk3C5Us9AL%3DBMWwgG25xqt85b6EjNpNik7jqM_4zdujvuQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CABL_bk3C5Us9AL%3DBMWwgG25xqt85b6EjNpNik7jqM_4zdujvuQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CAL0P1EX1k0TcAGstM9WhvjrgdfYpqz0nLfxnOpB6w4GVnvfPMw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

