summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2014-11-25 14:27:46 -0500
committerSimon Charette <charette.s@gmail.com>2014-11-25 15:28:21 -0500
commit3a9aa155e2f7326df669953980ac87e78e932c43 (patch)
tree7ae033dc73f374b35097d640c2e8d2e26127b3c1 /tests
parentf9c4e14aeca7df79991bca8ac2d743953cbd095c (diff)
Fixed #23915 -- Made sure m2m fields through non-pk to_field are allowed in the admin.
refs #23754, #23862
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_views/models.py12
-rw-r--r--tests/admin_views/tests.py12
2 files changed, 13 insertions, 11 deletions
diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py
index 5101ea5463..abf6035e86 100644
--- a/tests/admin_views/models.py
+++ b/tests/admin_views/models.py
@@ -855,13 +855,19 @@ class InlineReferer(models.Model):
refs = models.ManyToManyField(InlineReference)
-# Models for #23604
+# Models for #23604 and #23915
class Recipe(models.Model):
- pass
+ rname = models.CharField(max_length=20, unique=True)
class Ingredient(models.Model):
- recipes = models.ManyToManyField(Recipe)
+ iname = models.CharField(max_length=20, unique=True)
+ recipes = models.ManyToManyField(Recipe, through='RecipeIngredient')
+
+
+class RecipeIngredient(models.Model):
+ ingredient = models.ForeignKey(Ingredient, to_field='iname')
+ recipe = models.ForeignKey(Recipe, to_field='rname')
# Model for #23839
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index e6077f26af..0aec7a052f 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -616,16 +616,12 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
response = self.client.get("/test_admin/admin/admin_views/notreferenced/", {TO_FIELD_VAR: 'id'})
self.assertEqual(response.status_code, 200)
- # Specifying a field referenced by another model though a m2m should be allowed.
- # XXX: We're not testing against a non-primary key field since the admin doesn't
- # support it yet, ref #23862
- response = self.client.get("/test_admin/admin/admin_views/recipe/", {TO_FIELD_VAR: 'id'})
+ # #23915 - Specifying a field referenced by another model though a m2m should be allowed.
+ response = self.client.get("/test_admin/admin/admin_views/recipe/", {TO_FIELD_VAR: 'rname'})
self.assertEqual(response.status_code, 200)
- # #23604 - Specifying a field referenced through a reverse m2m relationship should be allowed.
- # XXX: We're not testing against a non-primary key field since the admin doesn't
- # support it yet, ref #23862
- response = self.client.get("/test_admin/admin/admin_views/ingredient/", {TO_FIELD_VAR: 'id'})
+ # #23604, #23915 - Specifying a field referenced through a reverse m2m relationship should be allowed.
+ response = self.client.get("/test_admin/admin/admin_views/ingredient/", {TO_FIELD_VAR: 'iname'})
self.assertEqual(response.status_code, 200)
# #23329 - Specifying a field that is not referred by any other model directly registered