There already exists create method that does exactly what you need: obj = SomeModel.objects.create(name='foo', age=42)
On Fri, Oct 12, 2012 at 2:33 PM, David Winterbottom < [email protected]> wrote: > While such a change is initially appealing, it violates the command-query > separation principle in that a 'command' method such as 'save' should not > return anything. > http://en.wikipedia.org/wiki/Command-query_separation > > Hence, it's not a good idea to make this change. It's more important to > have clearly purposed methods than saving a line of code. > > David > > > On 12 October 2012 14:25, Chris Wilson <[email protected]> wrote: > >> Hi all, >> >> If the save() method returned the object itself, then we could chain it >> like this: >> >> old_status = Status(last_contact=None).**save() >> >> Instead of having to do this: >> >> old_status = Status(last_contact=None) >> old_status.save() >> >> It's a trivial one-line change to the Model class and I don't think it >> would break backwards compatibility, as I doubt that anyone is relying on >> the save() method returning None. Should I submit a patch? >> >> Cheers, Chris. >> -- >> Aptivate | http://www.aptivate.org | Phone: +44 1223 967 838 >> Future Business, Cam City FC, Milton Rd, Cambridge, CB4 1UY, UK >> >> Aptivate is a not-for-profit company registered in England and Wales >> with company number 04980791. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers" group. >> To post to this group, send email to >> django-developers@**googlegroups.com<[email protected]> >> . >> To unsubscribe from this group, send email to >> django-developers+unsubscribe@**googlegroups.com<django-developers%[email protected]> >> . >> For more options, visit this group at http://groups.google.com/** >> group/django-developers?hl=en<http://groups.google.com/group/django-developers?hl=en> >> . >> >> >> > > > -- > *David Winterbottom* > Head of Programming > > Tangent Labs > 84-86 Great Portland Street > London W1W 7NR > England, UK > > -- > 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. > -- 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.
