diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py
index 79c6f8e1ea3..3899a166ca7 100644
--- a/django/core/management/commands/migrate.py
+++ b/django/core/management/commands/migrate.py
@@ -188,8 +188,9 @@ class Command(BaseCommand):
)
else:
if targets[0][1] is None:
- self.stdout.write(self.style.MIGRATE_LABEL(
- " Unapply all migrations: ") + "%s" % targets[0][0]
+ self.stdout.write(
+ self.style.MIGRATE_LABEL(' Unapply all migrations: ') +
+ str(targets[0][0])
)
else:
self.stdout.write(self.style.MIGRATE_LABEL(
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
index 052d053535c..094741d9528 100644
--- a/docs/_ext/djangodocs.py
+++ b/docs/_ext/djangodocs.py
@@ -351,7 +351,7 @@ class ConsoleDirective(CodeBlock):
if env.app.builder.name not in ('djangohtml', 'json'):
return [lit_blk_obj]
- lit_blk_obj['uid'] = '%s' % env.new_serialno('console')
+ lit_blk_obj['uid'] = str(env.new_serialno('console'))
# Only add the tabbed UI if there is actually a Windows-specific
# version of the CLI example.
win_content = code_block_to_win(self.content)
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index da006153105..f768172909e 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -3055,14 +3055,14 @@ class AdminViewListEditable(TestCase):
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
- "form-0-id": "%s" % self.per1.pk,
+ "form-0-id": str(self.per1.pk),
"form-1-gender": "2",
- "form-1-id": "%s" % self.per2.pk,
+ "form-1-id": str(self.per2.pk),
"form-2-alive": "checked",
"form-2-gender": "1",
- "form-2-id": "%s" % self.per3.pk,
+ "form-2-id": str(self.per3.pk),
"_save": "Save",
}
@@ -3077,14 +3077,14 @@ class AdminViewListEditable(TestCase):
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
- "form-0-id": "%s" % self.per1.pk,
+ "form-0-id": str(self.per1.pk),
"form-1-gender": "2",
- "form-1-id": "%s" % self.per2.pk,
+ "form-1-id": str(self.per2.pk),
"form-2-alive": "checked",
"form-2-gender": "1",
- "form-2-id": "%s" % self.per3.pk,
+ "form-2-id": str(self.per3.pk),
"_save": "Save",
}
@@ -3099,11 +3099,11 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "2",
"form-MAX_NUM_FORMS": "0",
- "form-0-id": "%s" % self.per1.pk,
+ "form-0-id": str(self.per1.pk),
"form-0-gender": "1",
"form-0-alive": "checked",
- "form-1-id": "%s" % self.per3.pk,
+ "form-1-id": str(self.per3.pk),
"form-1-gender": "1",
"form-1-alive": "checked",
@@ -3119,7 +3119,7 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "1",
"form-MAX_NUM_FORMS": "0",
- "form-0-id": "%s" % self.per1.pk,
+ "form-0-id": str(self.per1.pk),
"form-0-gender": "1",
"_save": "Save",
@@ -3209,7 +3209,7 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "1",
"form-MAX_NUM_FORMS": "0",
- "form-0-id": "%s" % self.per2.pk,
+ "form-0-id": str(self.per2.pk),
"form-0-alive": "1",
"form-0-gender": "2",
@@ -3227,7 +3227,7 @@ class AdminViewListEditable(TestCase):
"form-INITIAL_FORMS": "1",
"form-MAX_NUM_FORMS": "0",
- "form-0-id": "%s" % self.per2.pk,
+ "form-0-id": str(self.per2.pk),
"form-0-alive": "1",
"form-0-gender": "2",
@@ -3334,14 +3334,14 @@ class AdminViewListEditable(TestCase):
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
- "form-0-id": "%s" % self.per1.pk,
+ "form-0-id": str(self.per1.pk),
"form-1-gender": "2",
- "form-1-id": "%s" % self.per2.pk,
+ "form-1-id": str(self.per2.pk),
"form-2-alive": "checked",
"form-2-gender": "1",
- "form-2-id": "%s" % self.per3.pk,
+ "form-2-id": str(self.per3.pk),
"_save": "Save",
"_selected_action": ['1'],
diff --git a/tests/admin_views/views.py b/tests/admin_views/views.py
index 2cda42fe549..430f084693f 100644
--- a/tests/admin_views/views.py
+++ b/tests/admin_views/views.py
@@ -4,9 +4,9 @@ from django.http import HttpResponse
@staff_member_required
def secure_view(request):
- return HttpResponse('%s' % request.POST)
+ return HttpResponse(str(request.POST))
@staff_member_required(redirect_field_name='myfield')
def secure_view2(request):
- return HttpResponse('%s' % request.POST)
+ return HttpResponse(str(request.POST))
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index b255d2188a1..3d9f396d2d1 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -237,7 +237,7 @@ class AdminForeignKeyRawIdWidget(TestDataMixin, TestCase):
pk = band.pk
band.delete()
post_data = {
- "main_band": '%s' % pk,
+ "main_band": str(pk),
}
# Try posting with a nonexistent pk in a raw id field: this
# should result in an error message, not a server exception.
diff --git a/tests/expressions/models.py b/tests/expressions/models.py
index 6e1ce37b108..02836e653ea 100644
--- a/tests/expressions/models.py
+++ b/tests/expressions/models.py
@@ -81,7 +81,7 @@ class Time(models.Model):
time = models.TimeField(null=True)
def __str__(self):
- return "%s" % self.time
+ return str(self.time)
class SimulationRun(models.Model):
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
index b9f678a13a0..0ce6eea1e40 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -77,9 +77,9 @@ class GenericAdminViewTest(TestDataMixin, TestCase):
"generic_inline_admin-media-content_type-object_id-TOTAL_FORMS": "3",
"generic_inline_admin-media-content_type-object_id-INITIAL_FORMS": "2",
"generic_inline_admin-media-content_type-object_id-MAX_NUM_FORMS": "0",
- "generic_inline_admin-media-content_type-object_id-0-id": "%d" % self.mp3_media_pk,
+ "generic_inline_admin-media-content_type-object_id-0-id": str(self.mp3_media_pk),
"generic_inline_admin-media-content_type-object_id-0-url": "http://example.com/podcast.mp3",
- "generic_inline_admin-media-content_type-object_id-1-id": "%d" % self.png_media_pk,
+ "generic_inline_admin-media-content_type-object_id-1-id": str(self.png_media_pk),
"generic_inline_admin-media-content_type-object_id-1-url": "http://example.com/logo.png",
"generic_inline_admin-media-content_type-object_id-2-id": "",
"generic_inline_admin-media-content_type-object_id-2-url": "",
@@ -250,7 +250,7 @@ class GenericInlineAdminWithUniqueTogetherTest(TestDataMixin, TestCase):
"generic_inline_admin-phonenumber-content_type-object_id-MAX_NUM_FORMS": "0",
"generic_inline_admin-phonenumber-content_type-object_id-0-id": "",
"generic_inline_admin-phonenumber-content_type-object_id-0-phone_number": "555-555-5555",
- "generic_inline_admin-phonenumber-content_type-object_id-0-category": "%s" % category_id,
+ "generic_inline_admin-phonenumber-content_type-object_id-0-category": str(category_id),
}
response = self.client.get(reverse('admin:generic_inline_admin_contact_add'))
self.assertEqual(response.status_code, 200)
diff --git a/tests/m2m_through_regress/models.py b/tests/m2m_through_regress/models.py
index 7d64e7cf754..7042e31d0f3 100644
--- a/tests/m2m_through_regress/models.py
+++ b/tests/m2m_through_regress/models.py
@@ -40,7 +40,7 @@ class Car(models.Model):
drivers = models.ManyToManyField('Driver', through='CarDriver')
def __str__(self):
- return "%s" % self.make
+ return str(self.make)
class Driver(models.Model):
@@ -50,7 +50,7 @@ class Driver(models.Model):
ordering = ('name',)
def __str__(self):
- return "%s" % self.name
+ return str(self.name)
class CarDriver(models.Model):
diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py
index 097fd32f6a9..90e5cb1bd8f 100644
--- a/tests/model_formsets/tests.py
+++ b/tests/model_formsets/tests.py
@@ -1756,7 +1756,7 @@ class TestModelFormsetOverridesTroughFormMeta(TestCase):
PoetFormSet = modelformset_factory(Poet, fields="__all__", widgets=widgets)
form = PoetFormSet.form()
self.assertHTMLEqual(
- "%s" % form['name'],
+ str(form['name']),
''
)
@@ -1767,7 +1767,7 @@ class TestModelFormsetOverridesTroughFormMeta(TestCase):
BookFormSet = inlineformset_factory(Author, Book, widgets=widgets, fields="__all__")
form = BookFormSet.form()
self.assertHTMLEqual(
- "%s" % form['title'],
+ str(form['title']),
''
)
diff --git a/tests/queries/models.py b/tests/queries/models.py
index e9eec5718dd..fd994170dd1 100644
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -386,7 +386,7 @@ class Node(models.Model):
parent = models.ForeignKey("self", models.SET_NULL, to_field="num", null=True)
def __str__(self):
- return "%s" % self.num
+ return str(self.num)
# Bug #12252
@@ -604,7 +604,7 @@ class Order(models.Model):
ordering = ('pk',)
def __str__(self):
- return '%s' % self.pk
+ return str(self.pk)
class OrderItem(models.Model):
@@ -615,7 +615,7 @@ class OrderItem(models.Model):
ordering = ('pk',)
def __str__(self):
- return '%s' % self.pk
+ return str(self.pk)
class BaseUser(models.Model):
diff --git a/tests/responses/tests.py b/tests/responses/tests.py
index 934e4dfe600..2c161ee3521 100644
--- a/tests/responses/tests.py
+++ b/tests/responses/tests.py
@@ -145,7 +145,7 @@ class HttpResponseTests(SimpleTestCase):
self.assertEqual(r.content, content.encode(UTF8))
def test_generator_cache(self):
- generator = ("{}".format(i) for i in range(10))
+ generator = (str(i) for i in range(10))
response = HttpResponse(content=generator)
self.assertEqual(response.content, b'0123456789')
with self.assertRaises(StopIteration):
diff --git a/tests/serializers/models/base.py b/tests/serializers/models/base.py
index 7d3a64452b6..0004099f191 100644
--- a/tests/serializers/models/base.py
+++ b/tests/serializers/models/base.py
@@ -108,7 +108,7 @@ class Team:
raise NotImplementedError("Not so simple")
def to_string(self):
- return "%s" % self.title
+ return str(self.title)
class TeamField(models.CharField):
diff --git a/tests/template_tests/templatetags/custom.py b/tests/template_tests/templatetags/custom.py
index a5e1b33c67c..da7dd0a8781 100644
--- a/tests/template_tests/templatetags/custom.py
+++ b/tests/template_tests/templatetags/custom.py
@@ -170,12 +170,12 @@ def escape_format_html(context):
@register.simple_tag(takes_context=True)
def current_app(context):
- return "%s" % context.current_app
+ return str(context.current_app)
@register.simple_tag(takes_context=True)
def use_l10n(context):
- return "%s" % context.use_l10n
+ return str(context.use_l10n)
@register.simple_tag(name='minustwo')