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 unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



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 pattern and one
> > I frequently use myself. The problem is that the model instance
> > namespace is a precious resource, and using up any more of it than we
> > already do can easily lead to backwards-compatibility problems. In this
> > case, I don't think turning a one-liner into a shorter one-liner
> > justifies using up more of that namespace.
>
> > Carl
>
> I suggest implementing .save(only_fields=list_of_fields).
>
> That should not be hard to implement and will not consume the namespace of
> models. Signals are fired properly. In addition, update() would be a bit
> strange instance method: it updates the specified fields by the kwargs (the
> instance's field values do not matter). In addition, after the update the
> instance's fields are not updated to reflect what was just saved.
>
>  - Anssi

-- 
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 unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



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)

This helpers are particularly useful in writing tests, may be makes sense 
including them not to ``djanog.db.models`` but to ``django.test`` or 
``django.test.tools``.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/FxGwLxwM8SAJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Django template filters floatformat and intcomma: speed issues

2012-11-03 Thread Kee
Hello,

I was generating a lagrge table with django and wondered why response is so 
slow (it has ~ 2000 x 10), so I rewrote
profiled ``floatformat`` and ``intcomma`` and wrote down their 
implementations using builtin functions only.

Take a look: https://gist.github.com/4007717

Floatformat became faster almost 65 times, and intcomma became almost 6 
times faster.

Of course I understand that Django template engine is not the fast one and 
for speed I need to use other solutions.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/cM-44Hff3U8J.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: Python 3 and you

2011-11-11 Thread Kee
Jannis, that's great news indeed, I'll help with testing.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/jzva36TUYGcJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.