#901: [patch] Reload method for models
--------------------------------------+-------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Status: reopened | Component: Core framework
Version: | Resolution:
Keywords: | Stage: Design decision
needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
--------------------------------------+-------------------------------------
Changes (by Simon Litchfield <[EMAIL PROTECTED]>):
* status: closed => reopened
* resolution: wontfix =>
* stage: Unreviewed => Design decision needed
Comment:
I've needed to reload() during save().
During save(), after calling the super().save(), sometimes I needed to
update some related records, via the ORM and/or manual SQL.
I can't seem to set/replace self post save(); and I can't reload(); so I
came up with the below hackish workaround for my specific model attribute
(rtree) that was causing problems elsewhere by not being updated --
{{{
...
super(Category, self).save()
...
if cascade:
self._save_children()
# can't set/replace self, no reload() method. weird_magic.
weird_magic = Category.objects.get(pk=self.id)
self.rtree = weird_magic.rtree
}}}
Obviously, I'd prefer to --
{{{
...
super(Category, self).save()
...
if cascade:
self._save_children()
self.reload()
}}}
I was also surprised that the following didn't work. Trying to set self
was completely ignored for some reason, presumably because it thought it
already had the instance loaded --
{{{
...
super(Category, self).save()
...
if cascade:
self._save_children()
self = Category.objects.get(id=self.id)
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/901#comment:3>
Django Code <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
-~----------~----~----~----~------~----~------~--~---