Filtering results based on the value of other fields in the form - issue when i reselect the first field then second field does none change to none #1339
issue: when i reselect the first field then second field does none change to none
from apps.home.models import *
class getdegree_view(autocomplete.Select2QuerySetView):
def get_queryset(self):
# Don't forget to filter out results depending on the visitor !
if not self.request.user.is_authenticated:
queryset = degree.objects.none()
return queryset
getapprovedstf = get_approved_staffs_joined_objects('staff_working_details', Office_Code_id=self.request.user.office_code_id)
qs = degree.objects.all()
if self.q:
qs = qs.filter(name__istartswith=self.q)
return qs
class getdegreesub_view(autocomplete.Select2QuerySetView):
def get_queryset(self):
if not self.request.user.is_authenticated:
return degreesub.objects.none()
qs = degreesub.objects.all()
degree = self.forwarded.get('degree', None)
if degree:
qs = qs.filter(degree=degree)
if self.q:
qs = qs.filter(name__istartswith=self.q)
return qs
widgets = {
"course_admn_date": DatePickerInput(),
"course_completion_date": DatePickerInput(),
"pass_date": DatePickerInput(),
'degree': autocomplete.ModelSelect2(
url='getdegree_view',
attrs={
# Set some placeholder
'data-placeholder': '--Select--',
# Only trigger autocompletion after 3 characters have been typed
'data-minimum-input-length': 0,
'style': 'width: 100%;' # Set the width to 100%
},),
'degreesubject': autocomplete.ModelSelect2(
url='getdegreesub_view',
forward=['degree'],
attrs={
# Set some placeholder
'data-placeholder': '--Select--',
# Only trigger autocompletion after 3 characters have been typed
'data-minimum-input-length': 0,
'style': 'width: 100%;' # Set the width to 100%
},)
}
issue: when i reselect the first field then second field does none change to none