Rok
Rok

Reputation: 1500

Django trans tag within a default filter

Does anyone know how this could properly be written in Django?

{{ mu.expiry_date|default:"{% trans 'Free User' %}"}}

Obviously, the above does not work since it contains a tag within a tag's filter.

Upvotes: 23

Views: 3944

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375634

Templates have an underscore syntax for translation also:

{{ mu.expiry_date|default:_("Free User")}}

Upvotes: 50

Related Questions