Re: Pickling a QuerySet

2011-09-02 Thread Kevin
Thank you for this Tom, it's been awhile since I read about the QuerySet API. Kayode: I'm not sure you can export such data as a CSV. Why do you need the date exported in this manner? You can export the exact data from the database into a CSV, but re-importing would need a bit of work. I have

Re: Pickling a QuerySet

2011-09-02 Thread Tom Evans
On Fri, Sep 2, 2011 at 11:05 AM, Kevin wrote: > An interesting question here, not sure if anybody has tried to pickle > their QuerySets before. > Not only have people tried this before, but there is an entry in the manual about it: https://docs.djangoproject.com/en/1.3/ref/models/querysets/#pick

Re: Pickling a QuerySet

2011-09-02 Thread Kayode Odeyemi
Thanks for this. I have a question. Is it possible to pickle a QuerySet and write to csv? I have been trying to use pickle to achieve the same stuff you just did. But I guess I've not been patient enough. Thanks On Fri, Sep 2, 2011 at 11:17 AM, Kevin wrote: > Wow! This is very interesting an

Re: Pickling a QuerySet

2011-09-02 Thread Kevin
Wow! This is very interesting and I did not expect the results. The following: >>> dat = pickle.loads(open('kbase.dat','rb').read()) >>> for item in dat: ... item.save() Worked flawlessly! It recreated all the data in the database that I removed to see what would happen if I unpickled it and

Pickling a QuerySet

2011-09-02 Thread Kevin
An interesting question here, not sure if anybody has tried to pickle their QuerySets before. Here's an example that does work: entry_list = Entry.objects.all() response = HttpResponse(pickle.dumps(entry_list),mimetype='application/x- pickle.python') response['Content-Dispo