1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed pk uniqueness validation for new objects created outside of a ModelForm. Also removed need for ModelForm to poke at Model._state.adding, keeping it an internal ORM concern.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14613 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer
2010-11-18 23:29:58 +00:00
parent 38ba3775ec
commit 008f333bac
5 changed files with 20 additions and 6 deletions

View File

@@ -1,16 +1,26 @@
from models import Worker
from django.core.exceptions import ValidationError
from django.test import TestCase
from models import Worker, NonAutoPK
class RelatedModelOrderedLookupTest(TestCase):
"""
Regression test for #10153: foreign key __gte and __lte lookups.
"""
# The bug is that the following queries would raise:
# "TypeError: Related Field has invalid lookup: gte"
def test_related_gte_lookup(self):
Worker.objects.filter(department__gte=0)
def test_related_lte_lookup(self):
Worker.objects.filter(department__lte=0)
class ModelValidationTest(TestCase):
def test_pk_validation(self):
one = NonAutoPK.objects.create(name="one")
again = NonAutoPK(name="one")
self.assertRaises(ValidationError, again.validate_unique)