1- from django .shortcuts import render_to_response
1+ from django .shortcuts import render
22from django .http import HttpResponseBadRequest , JsonResponse , HttpResponse
33from django import forms
4- from django .template import RequestContext
54import django_excel as excel
65from polls .models import Question , Choice
76
8- # No longer you need the following import statements if you use pyexcel >=0.2.2
9- import pyexcel .ext .xls
10- import pyexcel .ext .xlsx
11- import pyexcel .ext .ods3 # noqa
12-
13-
147data = [
158 [1 , 2 , 3 ],
169 [4 , 5 , 6 ]
@@ -31,15 +24,15 @@ def upload(request):
3124 file_name = "download" )
3225 else :
3326 form = UploadFileForm ()
34- return render_to_response (
27+ return render (
28+ request ,
3529 'upload_form.html' ,
3630 {
3731 'form' : form ,
3832 'title' : 'Excel file upload and download example' ,
3933 'header' : ('Please choose any excel file ' +
4034 'from your cloned repository:' )
41- },
42- context_instance = RequestContext (request ))
35+ })
4336
4437
4538def download (request , file_type ):
@@ -97,14 +90,14 @@ def choice_func(row):
9790 return HttpResponseBadRequest ()
9891 else :
9992 form = UploadFileForm ()
100- return render_to_response (
93+ return render (
94+ request ,
10195 'upload_form.html' ,
10296 {
10397 'form' : form ,
10498 'title' : 'Import excel data into database example' ,
10599 'header' : 'Please upload sample-data.xls:'
106- },
107- context_instance = RequestContext (request ))
100+ })
108101
109102
110103def import_sheet (request ):
@@ -121,9 +114,10 @@ def import_sheet(request):
121114 return HttpResponseBadRequest ()
122115 else :
123116 form = UploadFileForm ()
124- return render_to_response ('upload_form.html' ,
125- {'form' : form },
126- context_instance = RequestContext (request ))
117+ return render (
118+ request ,
119+ 'upload_form.html' ,
120+ {'form' : form })
127121
128122
129123def exchange (request , file_type ):
0 commit comments