I am new to Django and building a school system but am an experienced developer otherwise having firm grip over rails, .net, php & java.
I have the following class where on teacher add/edit form, I am trying to filter values in class drop down based on school. The value of school_id is saved in session but as you can see below pulling value from session fails in ModelForm, can someone please guide me on how to get the value from session here ? class TeacherForm(ModelForm): def __init__(self, *args, **kwargs): super(TeacherForm, self).__init__(*args, **kwargs) xclass = self.fields['xclass'].widget choices = [] #school_id = request.session['school_id'] # since this fails, I have hard coded the value 2 in line below for now school_id = 2 xclasses = Class.objects.filter(school=school_id) for c in xclasses: choices.append((c.id,c.name)) xclass.choices = choices -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.