Я пытался получить данные в request.GET data, однако при печати это дает мне пустые значения или None.
class SchoolMixin(ProfileTypeRequiredMixin, MultiplePermissionsRequiredMixin):
profile_type = 'manager'
permissions = {
'any': ('school.admin')
}
def dispatch(self, request, *args, **kwargs):
self.init_vars(request, *args, **kwargs)
return super(SchoolMixin, self).dispatch(request, *args, **kwargs)
def init_vars(self, request, *args, **kwargs):
self.schools = self.request.user.manager.school
self.vals(request)
def vals(self, request):
if not request.GET:
if self.schools.school_set.exists():
school = self.schools.school_set.all()[0].pk
else:
school = None
data = {
'school': school,
}
else:
data = request.GET
self.filter_form = forms.FilterForm(
data=data,
prefix='FILTER',
school_manager=request.user.manager,
user=request.user
)
self.filter_form.is_valid()
self.school = self.filter_form.cleaned_data['school']
def get_context_data(self, **kwargs):
data = super(SchoolMixin, self).get_context_data(**kwargs)
data['filter_form'] = self.filter_form
return data
class FilterForm(forms.Form):
school = forms.ModelChoiceField(
label=_('School'),
required=False,
queryset=School.objects.none(),
empty_label=_('School'),
widget=forms.Select(attrs={'class': 'form-control'})
)
....
def __init__(self, *args, **kwargs):
self.school_manager = kwargs.pop('manager')
self.user = kwargs.pop('user', None)
super(FilterForm, self).__init__(*args, **kwargs)
url (r '^ school / $', views.ExportView.as_view (), name = 'export'),
Я пробовал более старые ветвь, и я получаю значение request.GET, я использую self.request.GET, но все равно получаю пустой или None. Спасибо