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.
For more options, visit https://groups.google.com/d/optout.