0

stackoverflow society. I am working on django project where i need translation. But I could not translate the variable model field (testing_name) that is generated from other fields of form. Below are respective snippets:

Model:

class Homes(models.Model):
    testing_name = models.CharField(
        max_length=200, null=True, verbose_name=_("testing_name")
    )

Form:

class AdvertisementForm(forms.Form):
    transaction_type = forms.CharField(widget=forms.HiddenInput())
    category = cleaned_data.get("category")

    def clean(self):
        cleaned_data = super().clean()
        transaction_type = cleaned_data.get("transaction_type")
        category = cleaned_data.get("category")
        if category == "land":
            if land_area and city and land_area_unit:
                testing_name = _("Land is for %(transaction_type)s") % {
                    "transaction_type": transaction_type,
                }
                cleaned_data["testing_name"] = testing_name

HTML

<td>{% trans home.testing_name %}</td>

.po file content

msgid "Land is for %(transaction_type)s"
msgstr "Torpaq %(transaction_type)s"

transaction types are Rent or Sale.

Desired result is to translate testing_name of Homes model into other language: e.g. In english: Land is for sale. In azerbaijani: Torpaq satilir.

0 Answers0