On Mon, Jul 8, 2013 at 11:10 AM, sahitya pavurala <sahitya.pavur...@gmail.com> wrote: > Hi , > > Can you specify from where am i getting the data here . > Should I have to retrieve the data again from the database . > > my view function has this code : > if Mice.objects.filter(pk=item).exists() == False: > invalidlist.append(item) > inputlist.remove(item) > for item in inputlist: > datalist = > serializers.serialize('python',Mice.objects.filter(pk = item)) > for i in datalist: > fulldata_list.append(i)
If it's your code, you should know where you're getting the data from. Run it in the debugger and step through it and see. I have the code that gets the data in a function (get_data) that I can call from different functions in my view depending on the URL. > > > > On Monday, July 8, 2013 12:59:33 PM UTC-4, larry....@gmail.com wrote: >> >> On Mon, Jul 8, 2013 at 10:30 AM, sahitya pavurala >> <sahitya....@gmail.com> wrote: >> > >> > Hi , >> > >> > >> > I am new to Django and I would be glad if i can get help on this . >> > >> > I am generating a html page where i get a table containing fields and >> > values >> > of a database . >> > I want to download this table as a file (preferably as an excel file ) . >> > How can i do this ? >> >> I use the python csv lib (http://docs.python.org/2/library/csv.html) >> and do something like this: >> >> def download_table(self, request): >> from django.http import HttpResponse >> from datetime import date >> import csv >> >> response = HttpResponse(mimetype='text/csv') >> response['Content-disposition'] = "attachment; >> filename=%s_%s_%s.csv" % ( >> request.user.username.lower(), >> self.report.name, >> date.today()) >> >> writer = csv.writer(response, dialect=csv.excel) >> data = self.get_data() >> rows = [] >> rows.append(self.get_headers()) >> rows += data >> for row in rows: >> writer.writerow(row) >> return response -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.