# HG changeset patch
# Parent 41ac0dddde05f44ea562ef29004b3cf82c79420d

diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -232,13 +232,13 @@
         try:
             related_url = reverse('admin:%s_%s_add' % info, current_app=self.admin_site.name)
         except NoReverseMatch:
-            info = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())
-            related_url = '%s%s/%s/add/' % info
+            prefix, loc, item = (self.admin_site.root_path, rel_to._meta.app_label, rel_to._meta.object_name.lower())
+            if prefix is None:
+                prefix = settings.ADMIN_MEDIA_URL
+            related_url = '%s%s/%s/add/' % (prefix, loc, item)
         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:
-            # TODO: "id_" is hard-coded here. This should instead use the correct
-            # API to determine the ID dynamically.
             output.append(u'<a href="%s" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> ' % \
                 (related_url, name))
             output.append(u'<img src="%simg/admin/icon_addlink.gif" width="10" height="10" alt="%s"/></a>' % (settings.ADMIN_MEDIA_PREFIX, _('Add Another')))
