Django ManyToMany field has automatically all the Users in admin panel

Question:

class Course(models.Model):
    students = models.ManyToManyField(User, verbose_name='Students', null=True, blank=True)

enter image description here

I want to add course enrollment to model Course
but my manytomanyfield already has all the users and I can’t even remove any of them. What should I do? I want "Students" to be a list of users who takes the course.

Asked By: ESP

||

Answers:

No! The student named (references to the student objects) are listed there as options of a multiple select widget but they are not actually selected. To select students for the course you would hold down the control key and click and the appropriate student’s names (control key on windows) . You could also just click on a single student’s name in a case where it’s a single student course .

And if you are worried about the admin page displaying all the users at once, trying looking at the django-autocomplete app here is the link to their pypi page Django-Autocomplete-light app

Answered By: Brian Obot
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.