In the view.py I have (def Bypub) that sends data to a template and paginates it. I have a second (def TextFile) that uses the same data to send to a CSV file. I would like to combine the two (def Bypub and def TextFile) together into def Bypub, but I'm not sure how to write the statements to combine two responses.
def Bypub(request): data retrieved to create a list ..... list.append(publications) paginator = Paginator(list, 10) #number of records per page try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: pub_list = paginator.page(page) except (EmptyPage, InvalidPage): pub_list = paginator.page(paginator.num_pages) return render_to_response('search/searchresults_pub.html', { 'list' : list, 'pub_list' : pub_list, }, ) def TextFile(request): data retrieved to create a list ..... list.append(publications) response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=publication.csv' writer = csv.writer(response) writer.writerow(['Title', 'Authors']) for publication in list: writer.writerow([publication.pubtitle, publication.pubauthors]) return response --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---