#11527: Documentation and testing for F() assignment to model attributes
------------------------------------------+---------------------------------
 Reporter:  zacharyvoase                  |       Owner:  nobody    
   Status:  new                           |   Milestone:  1.1       
Component:  Database layer (models, ORM)  |     Version:  SVN       
 Keywords:                                |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 Add explicit documentation and regression tests for the use of
 `django.db.models.F()`-expressions when assigning directly to attributes
 on model instances (as opposed to just using them in batch `update()`
 calls).

 The pattern goes something like this:

 {{{
 >>> from django.db.models import F
 >>> from myapp.models import MyModel
 >>> obj = MyModel(count=1)
 >>> obj.save()
 >>> obj.count
 1
 >>> obj.count = F('count') + 2
 >>> obj.save()
 >>> obj = MyModel.objects.get(pk=obj.pk) # Necessary to reload here, as
 the `count` attribute will still be an Expression object.
 >>> obj.count
 3
 }}}

 This should ''not'' work on records which do not already exist, since
 `F()`-expressions only work in `UPDATE` queries.

 It's also important for this to work with any pre-save and post-save
 signal handlers defined in any of the django.contrib apps.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11527>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to