Skip to content

Commit 02f3daa

Browse files
committed
Removed interpolation of post_url_continue in the admin.
1 parent 59ddb79 commit 02f3daa

File tree

3 files changed

+1
-41
lines changed

3 files changed

+1
-41
lines changed

django/contrib/admin/options.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -807,16 +807,6 @@ def response_add(self, request, obj, post_url_continue=None):
807807
(opts.app_label, opts.module_name),
808808
args=(pk_value,),
809809
current_app=self.admin_site.name)
810-
else:
811-
try:
812-
post_url_continue = post_url_continue % pk_value
813-
warnings.warn(
814-
"The use of string formats for post_url_continue "
815-
"in ModelAdmin.response_add() is deprecated. Provide "
816-
"a pre-formatted url instead.",
817-
DeprecationWarning, stacklevel=2)
818-
except TypeError:
819-
pass
820810
if "_popup" in request.POST:
821811
post_url_continue += "?_popup=1"
822812
return HttpResponseRedirect(post_url_continue)

tests/regressiontests/admin_custom_urls/models.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ def response_add(self, request, obj, post_url_continue=None):
7171
request, obj, post_url_continue=reverse('admin:admin_custom_urls_car_history', args=[obj.pk]))
7272

7373

74-
class CarDeprecated(models.Model):
75-
""" This class must be removed in Django 1.6 """
76-
name = models.CharField(max_length=20)
77-
78-
class CarDeprecatedAdmin(admin.ModelAdmin):
79-
""" This class must be removed in Django 1.6 """
80-
def response_add(self, request, obj, post_url_continue=None):
81-
return super(CarDeprecatedAdmin, self).response_add(
82-
request, obj, post_url_continue='../%s/history/')
83-
84-
8574
admin.site.register(Action, ActionAdmin)
8675
admin.site.register(Person, PersonAdmin)
8776
admin.site.register(Car, CarAdmin)
88-
admin.site.register(CarDeprecated, CarDeprecatedAdmin)

tests/regressiontests/admin_custom_urls/tests.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.test import TestCase
88
from django.test.utils import override_settings
99

10-
from .models import Action, Person, Car, CarDeprecated
10+
from .models import Action, Person, Car
1111

1212

1313
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
@@ -122,21 +122,3 @@ def test_post_url_continue(self):
122122
self.assertEqual(len(cars), 1)
123123
self.assertRedirects(
124124
response, reverse('admin:admin_custom_urls_car_history', args=[cars[0].pk]))
125-
126-
def test_post_url_continue_string_formats(self):
127-
"""
128-
Ensures that string formats are accepted for post_url_continue. This
129-
is a deprecated functionality that will be removed in Django 1.6 along
130-
with this test.
131-
"""
132-
with warnings.catch_warnings(record=True) as w:
133-
post_data = { 'name': 'SuperFast', '_continue': '1' }
134-
self.assertEqual(Car.objects.count(), 0)
135-
response = self.client.post(
136-
reverse('admin:admin_custom_urls_cardeprecated_add'), post_data)
137-
cars = CarDeprecated.objects.all()
138-
self.assertEqual(len(cars), 1)
139-
self.assertRedirects(
140-
response, reverse('admin:admin_custom_urls_cardeprecated_history', args=[cars[0].pk]))
141-
self.assertEqual(len(w), 1)
142-
self.assertTrue(isinstance(w[0].message, DeprecationWarning))

0 commit comments

Comments
 (0)