diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index fb5acb5..3a7a6f2 100644
a
|
b
|
class ForeignKeyRawIdWidget(forms.TextInput):
|
149 | 149 | def label_for_value(self, value): |
150 | 150 | key = self.rel.get_related_field().name |
151 | 151 | obj = self.rel.to._default_manager.get(**{key: value}) |
152 | | return ' <strong>%s</strong>' % escape(truncate_words(obj, 14)) |
| 152 | related_url = '../../../%s/%s/%s/' % (obj._meta.app_label, |
| 153 | obj._meta.object_name.lower(), obj.pk) |
| 154 | return ' <strong><a href="%s">%s</a></strong>' % (related_url, |
| 155 | escape(truncate_words(obj, 14))) |
153 | 156 | |
154 | 157 | class ManyToManyRawIdWidget(ForeignKeyRawIdWidget): |
155 | 158 | """ |
diff --git a/tests/regressiontests/admin_widgets/models.py b/tests/regressiontests/admin_widgets/models.py
index 0c81ed3..0fc3dc2 100644
a
|
b
|
from django.db import models
|
4 | 4 | from django.core.files.storage import default_storage |
5 | 5 | from django.contrib.auth.models import User |
6 | 6 | |
7 | | class MyFileField(models.FileField): |
8 | | pass |
| 7 | class MyFileField(models.FileField): |
| 8 | pass |
9 | 9 | |
10 | 10 | class Member(models.Model): |
11 | 11 | name = models.CharField(max_length=100) |
… |
… |
Currently: <a target="_blank" href="%(STORAGE_URL)salbums/hybrid_theory.jpg">alb
|
107 | 107 | >>> rel = Album._meta.get_field('band').rel |
108 | 108 | >>> w = ForeignKeyRawIdWidget(rel) |
109 | 109 | >>> print conditional_escape(w.render('test', band.pk, attrs={})) |
110 | | <input type="text" name="test" value="1" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/band/?t=id" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong>Linkin Park</strong> |
| 110 | <input type="text" name="test" value="1" class="vForeignKeyRawIdAdminField" /><a href="../../../admin_widgets/band/?t=id" class="related-lookup" id="lookup_id_test" onclick="return showRelatedObjectLookupPopup(this);"> <img src="%(ADMIN_MEDIA_PREFIX)simg/admin/selector-search.gif" width="16" height="16" alt="Lookup" /></a> <strong><a href="../../../admin_widgets/band/1/">Linkin Park</a></strong> |
111 | 111 | |
112 | 112 | >>> m1 = Member.objects.create(pk=1, name='Chester') |
113 | 113 | >>> m2 = Member.objects.create(pk=2, name='Mike') |