STUDENT
========
id
Name
STUDENT_SECTION:
===============
id
Student (FK of student)
class_section
LOOKUP:
========
class StudentLookup(ModelLookup):
model = StudentSection
def get_item_id(self,item) :
return
item.student.id FORM:
=====
class StudentFilterForm(forms.Form):
student = student=selectable.AutoCompleteSelectMultipleField(
lookup_class=StudentLookup,
required = False,
)
When using
get_item_id function in lookup , form is invalid , but without this
get_item_id function form is valid.
Then I used
get_item function in lookup which made the form valid, but value of the student field in form is StudentSection table PK not Student table PK.
class StudentLookup(ModelLookup):
model = StudentSection
def get_item_id(self,item) :
return
item.student.id def get_item(self,value) :
return StudentSection.objects.get(student=value)