1 | from django import forms
|
---|
2 | from django.http import HttpResponseRedirect
|
---|
3 | from django.shortcuts import render_to_response
|
---|
4 |
|
---|
5 | class ZipFileForm(forms.Form):
|
---|
6 | gallery = forms.CharField()
|
---|
7 | zip_file = forms.FileField()
|
---|
8 |
|
---|
9 | def add_pictures_from_zip(request):
|
---|
10 | if request.method == 'POST':
|
---|
11 | form = ZipFileForm(request.POST, request.FILES)
|
---|
12 | if form.is_valid():
|
---|
13 | form.save()
|
---|
14 | return HttpResponseRedirect('/admin/dali/picture/')
|
---|
15 | else:
|
---|
16 | form = ZipFileForm()
|
---|
17 |
|
---|
18 | title = "Add multiple pictures"
|
---|
19 | return render_to_response('upload_zip_file.html', {'form': form, 'title': title})
|
---|