I have a model named ClassRoom
,
class ClassRoom(model.Model):
class_name = models.CharField(max_lenth=100)
students = models.ManyToManyField(User)
and view.py
like this.
def addstudents(request):
class_room = ClassRoom.objects.get(id=1)
class_name.students.add(request.user)
I added the students to ClassRoom
like this.
I wanted to list all the students in class, who joined today.
How can I filter this students by their joining time
?.
When we using django ManyToManyField
, then django create an extra table in database. In that table contains created
time. Can I filter using this field?