Re: Best way to export data from Django?
Thanks Melvyn. Using model_to_dict I can now see the ID.
Tom
On Saturday, August 18, 2012 12:15:58 AM UTC+1, Melvyn Sopacua wrote:
-- On Saturday, August 18, 2012 12:15:58 AM UTC+1, Melvyn Sopacua wrote:
On 17-8-2012 18:41, Tom wrote:
> I'm able to export the data this way, but I can't get the attributes
> of the full model as I would as if I was using the Django shell.
> Particularly important is the ID of an object, because without that I
> won't know which ID to update on the remote web service. That's why
> I'm only dealing with "created" objects for now.
Why not? You have full access to the created instance with the instance
argument passed to the post_save signal.
You could for example use:
from django.forms import model_to_dict
data = model_to_dict(instance)
print data
and you should see the pk there.
--
Melvyn Sopacua
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/rWI_IZfxXcQJ.
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home