mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #12749 -- Corrected a problem with validation of inline primary keys. Thanks to Chris.Wesseling@cwi.nl for the report, and nessita for the test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13034 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -3,7 +3,7 @@ from django.test import TestCase
|
||||
# local test models
|
||||
from models import Holder, Inner, InnerInline
|
||||
from models import Holder2, Inner2, Holder3, Inner3
|
||||
|
||||
from models import Person, OutfitItem, Fashionista
|
||||
|
||||
class TestInline(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
@@ -48,6 +48,22 @@ class TestInline(TestCase):
|
||||
# The '+' is dropped from the autogenerated form prefix (Author_books+)
|
||||
self.assertContains(response, 'id="id_Author_books-TOTAL_FORMS"')
|
||||
|
||||
def test_inline_primary(self):
|
||||
person = Person.objects.create(firstname='Imelda')
|
||||
item = OutfitItem.objects.create(name='Shoes')
|
||||
# Imelda likes shoes, but can't cary her own bags.
|
||||
data = {
|
||||
'shoppingweakness_set-TOTAL_FORMS': 1,
|
||||
'shoppingweakness_set-INITIAL_FORMS': 0,
|
||||
'shoppingweakness_set-MAX_NUM_FORMS': 0,
|
||||
'_save': u'Save',
|
||||
'person': person.id,
|
||||
'max_weight': 0,
|
||||
'shoppingweakness_set-0-item': item.id,
|
||||
}
|
||||
response = self.client.post('/test_admin/admin/admin_inlines/fashionista/add/', data)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(len(Fashionista.objects.filter(person__firstname='Imelda')), 1)
|
||||
|
||||
class TestInlineMedia(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
||||
Reference in New Issue
Block a user