User getting added to multiple permission groups instead of the one
In my application, when a user registers, they are identified as either a lecturer or a student. These are categorised as auth_groups, and users are assigned to one with these methods...
def register_student(self, data):
user = User.objects.create(
user_id = data["user_id"]
)
students_group = Group.objects.get(name = "students")
user.groups.add(students_group)
return user
def register_lecturer(self, data):
user = User.objects.create(
user_id = data["user_id"]
)
lecturers_group = Group.objects.get(name = "lecturers")
user.groups.add(lecturers_group)
return user
On the surface, this appeared to work fine, but when I went to write the test suite, the following issue occurred: When register_student
is called, the user is added to both the lecturer and student groups in the line user.groups.add(students_group)
.
I want to mention that "students" have more permissions than "lecturers".
Why is this happening? Thank you for any help!