UPDATE: ADDED. PLEASE PROVIDE AN EXAMPLE AND I ACCEPT THE BEST ANSWER
UPDATE 2: Explicit example is now included
Running this project when I asked about bulk_create in a separate thread. I was wondering if there is essentially a "bulk_save" way - insert if it does not exist or just upgrade if it already exists.
For instance:
class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) height = models.DecimalField(blank=True, null=True) weight = models.DecimalField(blank=True, null=True)
I have a list of dictionaries with key-value pairs for these fields. I would like to filter by name and then update the height and / or weight, as these of my players are still growing and conditioning. If there is no easy way to "bulk_save", a bulk update will also be useful.
Link: June 8, 2012 - patch get_or_create () in django project
Link to Bulk_update
source share