Skip to content

Commit

Permalink
Fixed #26620 -- Made Model.refresh_from_db() fail when passed unknown…
Browse files Browse the repository at this point in the history
… kwargs.
  • Loading branch information
intgr authored and timgraham committed May 18, 2016
1 parent a5c8072 commit b9ae662
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django/db/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def get_deferred_fields(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/models/instances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/basic/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ def test_refresh(self):
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()
Expand Down

0 comments on commit b9ae662

Please sign in to comment.