#12709: Refetch method for getting a fresh model instance
------------------------------------------+---------------------------------
 Reporter:  jukvalim                      |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Database layer (models, ORM)  |     Version:  1.1       
 Keywords:  refetch                       |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 It is often useful to get a fresh instance of a model object, with data
 from db. A typical case is testing some view code using the test client,
 when the
 view is supposed to save some model changes into database. For example:

 {{{
 client.post('some_url', {'id': obj.id, 'description': 'new'})
 fresh_obj = ObjClass.objects.get(pk=obj.pk)
 self.assertEqual('new', fresh_obj.description)
 }}}

 This ticket proposes adding a method to Model that can be used to fetch a
 "fresh" version of a model object from the database. It is functionally
 the same as the use of objects.get in the example above, but more
 convenient and elegant.

 {{{
 fresh_obj = obj.refetch()
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12709>
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 [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-updates?hl=en.

Reply via email to