About Translatable Strings and Migrations

If you want to make sure that the translations of verbose names and help texts won't have an effect on your Django migrations, you can optionally import gettext_noop as _ in the models.py when the makemigrations management command is called.

1
2
3
4
5
6
import sys

if "makemigrations" in sys.argv:
    from django.utils.translation import gettext_noop as _
else:
    from django.utils.translation import gettext_lazy as _

Tips and Tricks Programming Development Translations Django 4.2 Django 3.2 Django 2.2