Friday, September 2, 2011

Re: Pickling a QuerySet

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 a routine which imports from a CSV adding new data which
currently does not exist based on a unique field. It does not update
the data from CSV, although it is possible. As long as you export
either the primary key or have a unique field.

On Sep 2, 7:26 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Fri, Sep 2, 2011 at 11:05 AM, Kevin <kveron...@gmail.com> 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/#pickling-...
>
> wrt to your later question - how can you tell if the object already
> exists in the database - you need to understand what django does when
> you save a model, and how to customize that behaviour.
>
> https://docs.djangoproject.com/en/1.3/ref/models/instances/#what-happ...https://docs.djangoproject.com/en/1.3/ref/models/instances/#how-djang...https://docs.djangoproject.com/en/1.3/ref/models/instances/#forcing-a...
>
> Cheers
>
> Tom

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment