I have the following ModelForm:
class AttendanceForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
operation_id = kwargs['operation_id']
del kwargs['operation_id']
super(AttendanceForm, self).__init__(*args, **kwargs)
self.fields['deployment'].query_set = \
Deployment.objects.filter(operation__id=operation_id)
class Meta:
model = Attendance
When I manually create the form in the shell (using manage.py shell)
form = AttendanceForm(operation_id=1)
form.fields['deployment'].query_set
it returns the correct query_set, but when I call
form.as_p()
i get extra entries that weren't in the query_set? Does django cache the html output somehow? I looked through the source, but couldn't find any caching. What am I doing wrong?