mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #901 -- Added Model.refresh_from_db() method
Thanks to github aliases dbrgn, carljm, slurms, dfunckt, and timgraham for reviews.
This commit is contained in:
parent
912ad03226
commit
c7175fcdfe
9 changed files with 265 additions and 11 deletions
|
@ -32,3 +32,17 @@ class BigChild(Primary):
|
|||
class ChildProxy(Child):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class RefreshPrimaryProxy(Primary):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
def refresh_from_db(self, using=None, fields=None, **kwargs):
|
||||
# Reloads all deferred fields if any of the fields is deferred.
|
||||
if fields is not None:
|
||||
fields = set(fields)
|
||||
deferred_fields = self.get_deferred_fields()
|
||||
if fields.intersection(deferred_fields):
|
||||
fields = fields.union(deferred_fields)
|
||||
super(RefreshPrimaryProxy, self).refresh_from_db(using, fields, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue