13👍
✅
Django 1.9 added an asvar
component to blocktrans
(now called blocktranslate
). An example from the docs:
{% blocktranslate asvar the_title %}The title is {{ title }}.{% endblocktranslate %}
<title>{{ the_title }}</title>
<meta name="description" content="{{ the_title }}">
Unfortunately, it seems that before that was added you needed some other way of doing it.
5👍
That isn’t possible with the blocktrans tag.
However, you could use this captureas templatetag to capture the output of blocktrans.
{% captureas trans_value %}
{% blocktrans %}
This has some stuff in it which will be translated {{ foo }}.
{% endblocktrans %}
{% endcaptureas %}
{{ trans_value }}
- How do I update an object's members using a dict?
- Ignore a specific test using Django
- Django – disable one of system checks
- <django.db.models.fields.related.RelatedManager object at 0x7ff4e003d1d0> is not JSON serializable
- Django rest framework – PrimaryKeyRelatedField
Source:stackexchange.com