Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11532 -- Corrected the link used for edit_inline foreign keys …

…in admin when the admin is deployed using the old style admin.root approach. Thanks to JP for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11314 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 53d16b1175682f1ff97358b67190e4c935372b26 1 parent a135608
Russell Keith-Magee authored July 23, 2009
3  django/contrib/admin/widgets.py
@@ -224,7 +224,8 @@ def render(self, name, value, *args, **kwargs):
224 224
         try:
225 225
             related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)
226 226
         except NoReverseMatch:
227  
-            related_url = '../../../%s/%s/add/' % info
  227
+            info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())
  228
+            related_url = '%s%s/%s/add/' % info
228 229
         self.widget.choices = self.choices
229 230
         output = [self.widget.render(name, value, *args, **kwargs)]
230 231
         if rel_to in self.admin_site._registry: # If the related object has an admin interface:
9  tests/regressiontests/admin_widgets/tests.py
@@ -115,6 +115,7 @@ def testFilterChoicesByRequestUser(self):
115 115
 
116 116
 class AdminForeignKeyWidgetChangeList(DjangoTestCase):
117 117
     fixtures = ["admin-widgets-users.xml"]
  118
+    admin_root = '/widget_admin'
118 119
 
119 120
     def setUp(self):
120 121
         self.client.login(username="super", password="secret")
@@ -123,5 +124,9 @@ def tearDown(self):
123 124
         self.client.logout()
124 125
 
125 126
     def test_changelist_foreignkey(self):
126  
-        response = self.client.get('/widget_admin/admin_widgets/car/')
127  
-        self.failUnless('/widget_admin/auth/user/add/' in response.content)
  127
+        response = self.client.get('%s/admin_widgets/car/' % self.admin_root)
  128
+        self.failUnless('%s/auth/user/add/' % self.admin_root in response.content)
  129
+
  130
+class OldAdminForeignKeyWidgetChangeList(AdminForeignKeyWidgetChangeList):
  131
+    urls = 'regressiontests.admin_widgets.urls2'
  132
+    admin_root = '/deep/down/admin'
7  tests/regressiontests/admin_widgets/urls2.py
... ...
@@ -0,0 +1,7 @@
  1
+
  2
+from django.conf.urls.defaults import *
  3
+import widgetadmin
  4
+
  5
+urlpatterns = patterns('',
  6
+    (r'^deep/down/admin/(.*)', widgetadmin.site.root),
  7
+)

0 notes on commit 53d16b1

Please sign in to comment.
Something went wrong with that request. Please try again.