0
from django.utils.translation import ugettext_lazy

I got problem in this line for last 2 hours I try every method but failed, but when I checked the directory of django.utils.translation is someone else and directory of ugettext_lazy has someone else meanwhile django.utils.translation search ugettext_lazy in C:\Users\admin\AppData\Local\Programs\Python\Python310\Lib\site-packages\django\utils\translation_init_.py

but the ugettext_lazy directory has in C:\Users\admin\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\jedilsp\jedi\third_party\django-stubs\django-stubs\utils_init_.py

How to make it same directory

enter image description here

enter image description here

3 Answers3

0

The i at the end of the files extension means that the file is an interface you can read more in this related Q. One answer says:

"This file is merely a Python skeleton with the proper structure, call signature, and return values to correspond to the functions, attributes, classes, and methods specified in a module." -> the module in this case is translation

And if you are using a Django version > 2.2 ugettext_lazy was deprecated in v2.2 and no longer used in django v3+. Check your version of Django’s documentation regarding lazy translation, you could try:

from django.utils.translation import gettext_lazy as _
Jonatrios
  • 424
  • 2
  • 5
0

I got it there is two simple method to do that one is

copy that line or function or class from other directory and paste it to the directory where he finds that

Second is

use * after 'import' for example

from django.utils.translation import *
0

enter image description here

As shown in the picture, in fact, vscode has told us that the imported file here is already a wrong file, and it is not included in this package. As mentioned above, you could use "*" if you can't ensure the content to import.

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13