Hello,The default behaviour for saving object is very hard for big models,
especially if it contain TextField. For example if I change one small field
in a model and that run save() method it will generate UPDATE query for all
of the fields which is very slow.

Instead of that I do it like that:

post.status = 2
Post.objects.filter(pk=post.pk).update(status=post.status)

This code will update only status field. So, my proposal is to add those
special methods by default like that

post.update_status(2)

which will run query "UPDATE post_table SET post_table.status=1 WHERE
id={POST_ID}" instead of updating all of the fields in case of running
.save() method.

It's something like clean_{filedname} methods in the forms.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to