class OrganizationForm(forms.ModelForm):
class Meta:
model = Organization
fields = ['country', 'region', 'city', 'raion', 'category', 'subcategory', 'oplata']
def __init__(self, *args, **kwargs):
super(OrganizationForm, self).__init__(*args, **kwargs)
self.fields['country'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
self.fields['region'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
self.fields['city'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
self.fields['raion'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
self.fields['category'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
self.fields['subcategory'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
self.fields['oplata'].widget.attrs.update({'class': 'multiple-select', 'multiple': 'multiple'})
def org_exs(request):
if request.method == "POST":
form = forms.OrganizationForm(request.POST, request.FILES)
if form.is_valid():
pass
else:
form = forms.OrganizationForm()
if request.POST:
x = Organization.objects.filter(name=request.POST['name'])
context = {
'titlepage': 'Выгрузка организаций',
'form': form,
}
return render(request, 'mainbase/exs.html', context)
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" class="save btn btn-success">Сохранить</button>
<a href="javascript:history.go(-1)" class="save btn btn-danger">Отмена</a>
</form>