diff --git a/django/db/models/query.py b/django/db/models/query.py
index be42d02..48e911b 100644
a
|
b
|
class QuerySet(object):
|
414 | 414 | Returns a tuple of (object, created), where created is a boolean |
415 | 415 | specifying whether an object was created. |
416 | 416 | """ |
417 | | assert kwargs, \ |
418 | | 'get_or_create() must be passed at least one keyword argument' |
419 | 417 | defaults = kwargs.pop('defaults', {}) |
420 | 418 | lookup = kwargs.copy() |
421 | 419 | for f in self.model._meta.fields: |
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index 49284fb..b2a8889 100644
a
|
b
|
Django 1.4 also includes several smaller improvements worth noting:
|
480 | 480 | * Added the :djadminopt:`--no-location` option to the :djadmin:`makemessages` |
481 | 481 | command. |
482 | 482 | |
| 483 | * The :meth:`~django.db.models.query.QuerySet.get_or_create` method no longer |
| 484 | requires at least one keyword argument. |
| 485 | |
483 | 486 | .. _backwards-incompatible-changes-1.4: |
484 | 487 | |
485 | 488 | Backwards incompatible changes in 1.4 |
diff --git a/tests/modeltests/get_or_create/models.py b/tests/modeltests/get_or_create/models.py
index 1de5a6e..d97c6c2 100644
a
|
b
|
class Person(models.Model):
|
17 | 17 | def __unicode__(self): |
18 | 18 | return u'%s %s' % (self.first_name, self.last_name) |
19 | 19 | |
| 20 | |
| 21 | class DefaultPerson(models.Model): |
| 22 | first_name = models.CharField(max_length=100, default="Anonymous") |
| 23 | |
| 24 | |
20 | 25 | class ManualPrimaryKeyTest(models.Model): |
21 | 26 | id = models.IntegerField(primary_key=True) |
22 | 27 | data = models.CharField(max_length=100) |
diff --git a/tests/modeltests/get_or_create/tests.py b/tests/modeltests/get_or_create/tests.py
index 4cf4450..47c7fef 100644
a
|
b
|
from datetime import date
|
5 | 5 | from django.db import IntegrityError |
6 | 6 | from django.test import TestCase |
7 | 7 | |
8 | | from .models import Person, ManualPrimaryKeyTest |
| 8 | from .models import Person, DefaultPerson, ManualPrimaryKeyTest |
9 | 9 | |
10 | 10 | |
11 | 11 | class GetOrCreateTests(TestCase): |
… |
… |
class GetOrCreateTests(TestCase):
|
52 | 52 | ManualPrimaryKeyTest.objects.get_or_create, id=1, data="Different" |
53 | 53 | ) |
54 | 54 | self.assertEqual(ManualPrimaryKeyTest.objects.get(id=1).data, "Original") |
| 55 | |
| 56 | def test_get_or_create_empty(self): |
| 57 | try: |
| 58 | DefaultPerson.objects.get_or_create() |
| 59 | except AssertionError: |
| 60 | self.fail("If all the attributes on a model have defaults, we " |
| 61 | "shouldn't need to pass any arguments.") |