#901: [patch] Reload method for models
-------------------------------------+-------------------------------------
     Reporter:  andreas@…            |                    Owner:  adrian
         Type:  enhancement          |                   Status:  closed
    Component:  Core (Other)         |                  Version:
     Severity:  normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:  Design
    Has patch:  1                    |  decision needed
  Needs tests:  0                    |      Needs documentation:  0
Easy pickings:  0                    |  Patch needs improvement:  0
                                     |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by anonymous):

 I had more luck with:
 {{{
     def refresh_from_db(self):
         """Refreshes this instance from db
         https://code.djangoproject.com/ticket/901
         """
         from_db = self.__class__.objects.get(pk=self.pk)
         for field in self.__class__._meta.fields:
             setattr(self, field.name, getattr(from_db, field.name))
 }}}
 But I don't know enough to know if it's correct, only that it seems to
 work.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/901#comment:13>
Django <https://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 https://groups.google.com/groups/opt_out.


Reply via email to