> I'm very unconvinced that the idea in the ticket is worth it. It's a > two-liner if somebody wants to do this in their code, so whilst we *can* > add this method, adding yet another thing to Model namespace that also > adds to the documentation and things that need to be tested, etc, > doesn't seem worth it to me. We already have save(force_update=True) to > do an update. Adding the extra line to also populate some model fields > doesn't seem like a great API addition that we can't live without to me.
I'm probably just missing the obvious here, but what is the two-liner alternative? I thought that the alternative was to put all of the values you want to update in a dict and iterate through that dict and calling `setattr()` and then calling `save()` (like the `update()` method does) or just assign each value to your instance one line at a time and then call `save()`? I can live with that if cluttering the namespace is really that bad, but it does seem fairly inconvenient. Perhaps an `update_fields` argument could be added to `save()` (in keeping with `force_update` and `force_create`), and just move the code from `update()` into `save ()` if that argument isn't empty? I would really like to see `update_or_create()` implemented, though. Personally, I've found a need to use this pattern many times, and having this method to compliment `get_or_create()` would be far more convenient than the example Gary Wilson has given. There shouldn't be too much concern about this method clashing with anything in the Manager namespace. Similar to the above, I suppose a `force_update` argument could be added to `get_or_create()`, but that seems contradictory to the methods meaning as described by its name. I'm +0 for `Model.update()` and +1 for `Manager.update_or_create()`. Cheers. Tai. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
