Ticket #10993: patch.diff
File patch.diff, 1.4 KB (added by , 14 years ago) |
---|
-
django/db/models/query.py
357 357 Returns a tuple of (object, created), where created is a boolean 358 358 specifying whether an object was created. 359 359 """ 360 defaults = kwargs.pop('defaults', {}) 360 361 assert kwargs, \ 361 'get_or_create() must be passed at least one keyword argument' 362 defaults = kwargs.pop('defaults', {}) 362 'get_or_create() must be passed at least one lookup argument' 363 363 try: 364 364 self._for_write = True 365 365 return self.get(**kwargs), False -
tests/modeltests/get_or_create/tests.py
50 50 ManualPrimaryKeyTest.objects.get_or_create, id=1, data="Different" 51 51 ) 52 52 self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original") 53 54 # If you pass default values without lookup arguments you will get an 55 # error 56 self.assertRaises(AssertionError, Person.objects.get_or_create, 57 defaults={'first_name': "Tom", 58 'last_name': "Smith"})