Commits

Anonymous committed e761e9e

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.

  • Participants
  • Parent commits 6f79acf

Comments (0)

Files changed (3)

File django/contrib/admin/widgets.py

         try:
             related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)
         except NoReverseMatch:
-            related_url = '../../../%s/%s/add/' % info
+            info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())
+            related_url = '%s%s/%s/add/' % info
         self.widget.choices = self.choices
         output = [self.widget.render(name, value, *args, **kwargs)]
         if rel_to in self.admin_site._registry: # If the related object has an admin interface:

File tests/regressiontests/admin_widgets/tests.py

 
 class AdminForeignKeyWidgetChangeList(DjangoTestCase):
     fixtures = ["admin-widgets-users.xml"]
+    admin_root = '/widget_admin'
 
     def setUp(self):
         self.client.login(username="super", password="secret")
         self.client.logout()
 
     def test_changelist_foreignkey(self):
-        response = self.client.get('/widget_admin/admin_widgets/car/')
-        self.failUnless('/widget_admin/auth/user/add/' in response.content)
+        response = self.client.get('%s/admin_widgets/car/' % self.admin_root)
+        self.failUnless('%s/auth/user/add/' % self.admin_root in response.content)
+
+class OldAdminForeignKeyWidgetChangeList(AdminForeignKeyWidgetChangeList):
+    urls = 'regressiontests.admin_widgets.urls2'
+    admin_root = '/deep/down/admin'

File tests/regressiontests/admin_widgets/urls2.py

+
+from django.conf.urls.defaults import *
+import widgetadmin
+
+urlpatterns = patterns('',
+    (r'^deep/down/admin/(.*)', widgetadmin.site.root),
+)