django forms request

Solutions on MaxInterview for django forms request by the best coders in the world

showing results for - "django forms request"
Cyprien
17 Nov 2018
1class BookSubmitForm(ModelForm):
2    def __init__(self, *args, **kwargs):
3        self.request = kwargs.pop("request")
4        super(BookSubmitForm, self).__init__(*args, **kwargs)
5        self.fields["book"].queryset = Book.objects.filter(owner=self.request.user)
6        self.fields["whatever"].queryset = WhateverModel.objects.filter(user=self.request.user)
7