0

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?

1 Answer 1

4

The parameter is queryset, not query_set. See the documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.