About Lazy String Concatenation

When you use lazy translations for the values of attributes of classes, and want to combine a string of multiple translatable strings, you have to use format_lazy() function, instead of any other string concatenation method:

from django import forms
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _

class MyForm(forms.Form):
    q = forms.CharField(
        label=format_lazy(
            "{}: {}",
            _("Global search"),
            _("Enter a few characters for autosuggestion"),
        ),
        required=False,
    )

Tips and Tricks Programming Django 5.x Django 4.2 Django 3.2 Django 2.2