Saturday, October 2, 2010

Re: A better way of checking if a record exists

Bruno,

Great point. I've simplified my old code quite a bit with this
suggestion.

After creating a dictionary with 12 items in it, I use it for the
default in get_or_create, then:

[setattr(product, field, value) for field, value in
new_values.items()]
product.save()

Thanks,
Shawn

--
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