Tricky little problem here.  I am using horizontal_filter to assign a
massive amount of students to their advisors.
The horizontal filter works, but I see students from the entire
district.    How can I pre-filter the data going into the
filter_horizontal widget to only show students at the Advisor's
school?

Any advice on this and the model is helpful.

class Student(models.Model):
  student_id = models.CharField(max_length=20, primary_key=True)
#school assigned student id
  gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
  last_name = models.CharField(max_length=30)
  first_name = models.CharField(max_length=30)
  grade = models.IntegerField()
  school = models.ForeignKey(School)

#Advisors have a primary school, but can also support many schools.
class Advisor(models.Model):
  last_name = models.CharField(max_length=20)
  first_name= models.CharField(max_length=20)
  primary_school = models.ForeignKey(School)
  school = models.ManyToManyField(School,
related_name='school_advisor')
  student = models.ManyToManyField(Student,
related_name='student_advisor')
  email = models.EmailField()

class School(models.Model):
  school_name = models.CharField(max_length=200)
  school_num = models.IntegerField()


class AdvisorAdmin(admin.ModelAdmin):
  # How can I prefilter this set of students to only show students
  # where student.school = teacher.primary_school
  # currently I see all the students in the district
  filter_horizontal = ['student']

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to