django create view filter options

Solutions on MaxInterview for django create view filter options by the best coders in the world

showing results for - "django create view filter options"
Flavio
07 May 2016
1class FolderCreate(CreateView):
2    template_name = 'Form/folder_create.html'
3    form_class = FolderForm
4
5    def get_form_kwargs(self):
6        kwargs = super(FolderCreate, self).get_form_kwargs()
7        kwargs['user'] = self.request.user
8        return kwargs
Aidan
16 Oct 2020
1class FolderForm(forms.ModelForm):
2    class Meta:
3       model = Folder
4       fields = ['name', 'parent']
5
6    def __init__(self, *args, **kwargs):
7       user = kwargs.pop('user')
8       super(FolderForm, self).__init__(*args, **kwargs)
9       self.fields['parent'].queryset = Folder.objects.filter(user=user)