Loading django/db/models/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -646,7 +646,7 @@ class Model(six.with_metaclass(ModelBase)): if f.attname not in self.__dict__ } def refresh_from_db(self, using=None, fields=None, **kwargs): def refresh_from_db(self, using=None, fields=None): """ Reloads field values from the database. Loading docs/ref/models/instances.txt +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ in the ``from_db()`` method. Refreshing objects from database ================================ .. method:: Model.refresh_from_db(using=None, fields=None, **kwargs) .. method:: Model.refresh_from_db(using=None, fields=None) If you need to reload a model's values from the database, you can use the ``refresh_from_db()`` method. When this method is called without arguments the Loading tests/basic/tests.py +5 −0 Original line number Diff line number Diff line Loading @@ -690,6 +690,11 @@ class ModelRefreshTests(TestCase): a.refresh_from_db() self.assertEqual(a.pub_date, new_pub_date) def test_unknown_kwarg(self): s = SelfRef.objects.create() with self.assertRaises(TypeError): s.refresh_from_db(unknown_kwarg=10) def test_refresh_fk(self): s1 = SelfRef.objects.create() s2 = SelfRef.objects.create() Loading Loading
django/db/models/base.py +1 −1 Original line number Diff line number Diff line Loading @@ -646,7 +646,7 @@ class Model(six.with_metaclass(ModelBase)): if f.attname not in self.__dict__ } def refresh_from_db(self, using=None, fields=None, **kwargs): def refresh_from_db(self, using=None, fields=None): """ Reloads field values from the database. Loading
docs/ref/models/instances.txt +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ in the ``from_db()`` method. Refreshing objects from database ================================ .. method:: Model.refresh_from_db(using=None, fields=None, **kwargs) .. method:: Model.refresh_from_db(using=None, fields=None) If you need to reload a model's values from the database, you can use the ``refresh_from_db()`` method. When this method is called without arguments the Loading
tests/basic/tests.py +5 −0 Original line number Diff line number Diff line Loading @@ -690,6 +690,11 @@ class ModelRefreshTests(TestCase): a.refresh_from_db() self.assertEqual(a.pub_date, new_pub_date) def test_unknown_kwarg(self): s = SelfRef.objects.create() with self.assertRaises(TypeError): s.refresh_from_db(unknown_kwarg=10) def test_refresh_fk(self): s1 = SelfRef.objects.create() s2 = SelfRef.objects.create() Loading