Re: Pretty Django model instaces updating

2012-10-09 Thread Kee
I also propose these two little helpers, one is ``refresh()`` and other is ``update()`` https://gist.github.com/3859962 ``update()`` updates instance without calling ``save()`` and calling signals and returns updated instance (sometimes you want to update instance without involving save signals

Re: Pretty Django model instaces updating

2012-03-01 Thread Jeremy Dunck
On Thu, Mar 1, 2012 at 9:28 PM, Carl Meyer wrote: > The "only_fields" kwarg suggestion comes from ticket 4102, and it is > primarily intended as a performance optimization for large models by > only sending the values of certain fields to the database at all, > something that your proposed co

Re: Pretty Django model instaces updating

2012-03-01 Thread Anssi Kääriäinen
On Friday, March 2, 2012 7:28:30 AM UTC+2, Carl Meyer wrote: > > On 03/01/2012 09:46 PM, Tai Lee wrote: > > This is easy to achieve in your own code. Create your own BaseModel > > class that all your models subclass. Instead of using > > `.filter().update()`, do this: > > > > def update(self, **kw

Re: Pretty Django model instaces updating

2012-03-01 Thread Carl Meyer
On 03/01/2012 09:46 PM, Tai Lee wrote: > This is easy to achieve in your own code. Create your own BaseModel > class that all your models subclass. Instead of using > `.filter().update()`, do this: > > def update(self, **kwargs): > """ > Updates the fields specified in `kwargs` and the

Re: Pretty Django model instaces updating

2012-03-01 Thread Tai Lee
This is easy to achieve in your own code. Create your own BaseModel class that all your models subclass. Instead of using `.filter().update()`, do this: def update(self, **kwargs): """ Updates the fields specified in `kwargs` and then call `save()`. """ if kwargs:

Re: Pretty Django model instaces updating

2012-03-01 Thread Kee
Fully agree with Anssi Kääriäinen, the best approach is ``only_fields`` for save()`` On Mar 1, 11:45 pm, Anssi Kääriäinen wrote: > On Thursday, March 1, 2012 9:29:34 PM UTC+2, Carl Meyer wrote: > > > > > > Thanks for the suggestion. I agree that that's a useful

Re: Pretty Django model instaces updating

2012-03-01 Thread Anssi Kääriäinen
On Thursday, March 1, 2012 9:29:34 PM UTC+2, Carl Meyer wrote: > > > > Thanks for the suggestion. I agree that that's a useful pattern and one > I frequently use myself. The problem is that the model instance > namespace is a precious resource, and using up any m

Re: Pretty Django model instaces updating

2012-03-01 Thread Meir Kriheli
Hi, On Thu, Mar 1, 2012 at 9:29 PM, Carl Meyer wrote: > Hi Kee, > > On 03/01/2012 11:24 AM, Kee wrote: > > This helper could be used as an instance method in > > django.core.models.Model class: > > https://gist.github.com/1951748 > > Thanks for the suggestion. I agree that that's a useful patte

Re: Pretty Django model instaces updating

2012-03-01 Thread Carl Meyer
Hi Kee, On 03/01/2012 11:24 AM, Kee wrote: > This helper could be used as an instance method in > django.core.models.Model class: > https://gist.github.com/1951748 Thanks for the suggestion. I agree that that's a useful pattern and one I frequently use myself. The problem is that the model insta

Pretty Django model instaces updating

2012-03-01 Thread Kee
This helper could be used as an instance method in django.core.models.Model class: https://gist.github.com/1951748 -- 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. To