In Models.py of some app
email = models.EmailField (_ ('email address'), unique = True)
first_name = models.CharField (_ ('first name'), max_length = 30)
last_name = models.CharField (_ ('last name'), max_length = 150)

If these models are defined in the Django standard, or if you use Vscode's Django extension, you'll see ~ Field (_ (''), ...) as a completion of your input.

However, if you execute it in that state, NameError will occur.

Even if you look it upinitIt wasn't because I forgot to make .py.

What is the solution?
Current status,

  • Make Vscode ignore the error (No)
  • Quietly ban the notation
    I only know that.

Please teach.

  • Answer # 1

    It's a quick glance, and it's pretty speculative, but I think it's multilingual processing with gettext.

    Assuming there is speculation, for the time beingNameErrorIf you want to avoid

    import gettext
    #Initialize with language setting disabled
    tr = gettext.NullTranslations ()
    tr.install ()

    I think you can avoid it if you do it once at the beginning of the runtime.
    However, I don't know if it's some kind of App or django, but it may be better to support the language properly.
    For the time being, please search for "gettext" as a keyword.