How to inherit the user model in two apps in django rest,

387 views
Skip to first unread message

Shubham Joshi

unread,
Mar 26, 2019, 7:25:58 AM3/26/19
to Django users
I want to create 2 separate signup form 1 for teacher and 1 for a student for that I created 2 apps and its respective models but it gives an error 



==================
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'studentRegistration.groups'.
        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'studentRegistration.groups'.
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'teacherRegistration.groups'.
        HINT: Add or change a related_name argument to the definition for 'User.groups' or 'teacherRegistration.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'studentRegistration.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'studentRegistration.user_permissions'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'teacherRegistration.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'teacherRegistration.user_permissions'.
student.studentRegistration.groups: (fields.E304) Reverse accessor for 'studentRegistration.groups' clashes with reverse accessor for 'User.groups'.
        HINT: Add or change a related_name argument to the definition for 'studentRegistration.groups' or 'User.groups'.
student.studentRegistration.groups: (fields.E304) Reverse accessor for 'studentRegistration.groups' clashes with reverse accessor for 'teacherRegistration.groups'.
        HINT: Add or change a related_name argument to the definition for 'studentRegistration.groups' or 'teacherRegistration.groups'.
student.studentRegistration.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
        HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "pip install Pillow".
student.studentRegistration.parents_name: (fields.E120) CharFields must define a 'max_length' attribute.
student.studentRegistration.user_permissions: (fields.E304) Reverse accessor for 'studentRegistration.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'studentRegistration.user_permissions' or 'User.user_permissions'.
student.studentRegistration.user_permissions: (fields.E304) Reverse accessor for 'studentRegistration.user_permissions' clashes with reverse accessor for 'teacherRegistration.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'studentRegistration.user_permissions' or 'teacherRegistration.user_permissions'.
teacher.teacherRegistration.groups: (fields.E304) Reverse accessor for 'teacherRegistration.groups' clashes with reverse accessor for 'User.groups'.
        HINT: Add or change a related_name argument to the definition for 'teacherRegistration.groups' or 'User.groups'.
teacher.teacherRegistration.groups: (fields.E304) Reverse accessor for 'teacherRegistration.groups' clashes with reverse accessor for 'studentRegistration.groups'.
        HINT: Add or change a related_name argument to the definition for 'teacherRegistration.groups' or 'studentRegistration.groups'.
teacher.teacherRegistration.qualification: (fields.E120) CharFields must define a 'max_length' attribute.
teacher.teacherRegistration.subjectExperty: (fields.E120) CharFields must define a 'max_length' attribute.
teacher.teacherRegistration.user_permissions: (fields.E304) Reverse accessor for 'teacherRegistration.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'teacherRegistration.user_permissions' or 'User.user_permissions'.
teacher.teacherRegistration.user_permissions: (fields.E304) Reverse accessor for 'teacherRegistration.user_permissions' clashes with reverse accessor for 'studentRegistration.user_permissions'.
        HINT: Add or change a related_name argument to the definition for 'teacherRegistration.user_permissions' or 'studentRegistration.user_permissions'.

jgi...@caktusgroup.com

unread,
Mar 26, 2019, 8:06:14 AM3/26/19
to Django users
I'm not exactly sure what is happening with your models but a few places to investigate are these:

Since you are using `AbstractBaseUser` rather than `AbstractUser`:

* Looking at your code it seems like you missed assigning the `USERNAME_FIELD`
* You did not set your identifier (which I assume would be your username) to be `unique=True`



Good Luck,

Jeremy Gibson
email:      jgi...@caktusgroup.com
Reply all
Reply to author
Forward
0 new messages