diff -r 6a15d764cd1d django/contrib/admin/sites.py
a
|
b
|
|
152 | 152 | # URLs starting with 'r/' are for the "View on site" links. |
153 | 153 | elif url.startswith('r/'): |
154 | 154 | from django.contrib.contenttypes.views import shortcut |
155 | | return shortcut(request, *url.split('/')[1:]) |
| 155 | return shortcut(request, *url.split('/', 2)[1:]) |
156 | 156 | else: |
157 | 157 | if '/' in url: |
158 | 158 | return self.model_page(request, *url.split('/', 2)) |
diff -r 6a15d764cd1d tests/regressiontests/admin_views/models.py
a
|
b
|
|
121 | 121 | |
122 | 122 | def __unicode__(self): |
123 | 123 | return self.id |
| 124 | |
| 125 | def get_absolute_url(self): |
| 126 | return "/" + self.id |
124 | 127 | |
125 | 128 | class Color(models.Model): |
126 | 129 | value = models.CharField(max_length=10) |
diff -r 6a15d764cd1d tests/regressiontests/admin_views/tests.py
a
|
b
|
|
227 | 227 | '<a href="?surface__exact=y">Vertical</a>' in response.content, |
228 | 228 | "Changelist filter isn't showing options contained inside a model field 'choices' option named group." |
229 | 229 | ) |
| 230 | |
| 231 | def testShortcutWithSlash(self): |
| 232 | """Ensures the 'view on Site' links work for models with string PKs values that contain slashes.""" |
| 233 | obj = ModelWithStringPrimaryKey(id="pk/with/slashes") |
| 234 | obj.save() |
| 235 | content_type_pk = ContentType.objects.get_for_model(ModelWithStringPrimaryKey).pk |
| 236 | short_url = '/test_admin/%s/r/%s/%s/' % (self.urlbit, content_type_pk, obj.pk) |
| 237 | response = self.client.get(short_url) |
| 238 | self.assertRedirects(response, 'http://example.com%s' % obj.get_absolute_url(), |
| 239 | status_code=302, target_status_code=404) |
| 240 | |
230 | 241 | |
231 | 242 | def get_perm(Model, perm): |
232 | 243 | """Return the permission object, for the Model""" |