I have no fully experience on Django, mean I am fully a beginner on it. Here is my question ...
my Staff model is:
class Staffs(models.Model):
""" Staff models. """
teacher_of_section = models.ForeignKey(Sections, on_delete=models.CASCADE)
And that of Student model is:
class Students(models.Model):
""" Student models. """
section_name = models.ForeignKey(Sections, on_delete=models.CASCADE)
Lastly the form is:
class AddResultForm(forms.Form):
""" Forms that adds the students Result."""
student_list = []
students = Students.objects.filter(section_name=2)
try:
for student in students:
small_student = (student.id, str(student.admin.first_name))
student_list.append(small_student)
except:
student_list = []
From those models, I want to filter all students that fulfills
Staffs.teacher_of_section == Students.section_name
I tried to compare the value of the two and set the staff value to filter the students, but it can't work. I know it can work with JQuery, but I want to work with Django only. The form should filter all students that is similar section with Staff and drop the other students - it is many to many relationship of students and staffs. Kindly, I want help for this, it stucks me on the code for the days...