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

[1.0.X] Fixed #7510: the ModelAdmin now uses self.queryset instead of the default manager. Thanks, Alex Gaynor. Backport of r10314 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10320 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2009-04-01 15:07:13 +00:00
parent 53d5f27e75
commit 906f55bf09
3 changed files with 36 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ from django.contrib.admin.util import quote
from django.utils.html import escape
# local test models
from models import Article, CustomArticle, Section, ModelWithStringPrimaryKey, Persona, FooAccount, BarAccount
from models import Article, CustomArticle, Section, ModelWithStringPrimaryKey, Persona, FooAccount, BarAccount, EmptyModel
try:
set
@@ -836,3 +836,27 @@ class TestInlineNotEditable(TestCase):
"""
response = self.client.get('/test_admin/admin/admin_views/parent/add/')
self.failUnlessEqual(response.status_code, 200)
class AdminCustomQuerysetTest(TestCase):
fixtures = ['admin-views-users.xml']
def setUp(self):
self.client.login(username='super', password='secret')
self.pks = [EmptyModel.objects.create().id for i in range(3)]
def test_changelist_view(self):
response = self.client.get('/test_admin/admin/admin_views/emptymodel/')
for i in self.pks:
if i > 1:
self.assertContains(response, 'Primary key = %s' % i)
else:
self.assertNotContains(response, 'Primary key = %s' % i)
def test_change_view(self):
for i in self.pks:
response = self.client.get('/test_admin/admin/admin_views/emptymodel/%s/' % i)
if i > 1:
self.assertEqual(response.status_code, 200)
else:
self.assertEqual(response.status_code, 404)