trans And Translate Not Working On Any Pages

Viewed 546

Im copying Django Templates straight from Git and pasting them into overridden templates in my project (so there are no syntax errors), but I get this error message on every page that uses translate or trans:

Invalid block tag on line 38: 'translate', expected 'endblock'. Did you forget to register or load this tag?

My settings file is unchanged from when I began the project and as I said, im copying the code straight from the git repository. Im guessing the problem is in my settings.py file. Ive Googled and tried everything i can find but cant seem to find the problem.

Can anybody please help shed some light on what the issue might be?

Thank you.

PS I know im giving little code, but I cant think of how to offer more code without just pasting my whole settings.py file :s

1 Answers

According to Django documentation (and thanks to Gabriel for mentioning in the comments) you need to add {% load i18n %} toward the top of your template for being able to use translate and blocktranslate tags.

In Django 3.1 trans and blocktrans tags was renamed to translate and blocktranslate tags accordingly by keeping backwards compatibility.

Related