VSCode 中的 Django 目录不一样
from django.utils.translation import ugettext_lazy
在过去的两个小时中,我在这条线上遇到了问题,但我尝试了每种方法,但失败了,但是当我检查 django.utils.utils.translations.translation 的目录时,是 ugetText_lazy>的其他人和目录。同时还有其他人 django.utils.translation search ugetText_lazy 在C中: init _
。 jedilsp \ jedi \ third_party \ django-stubs \ django-stubs \ utils_ init> init
。
_ “ rel =“ nofollow noreferrer”>
此处。
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
文件扩展名末尾的
i
表示该文件是一个接口
,您可以阅读更多内容 在此相关问题中。一个答案是:“这个文件只是一个 Python 框架,具有正确的结构、调用签名和返回值,以对应于模块中指定的函数、属性、类和方法。” ->本例中的模块是
translation
如果您使用的是 Django 版本 > 2.2
ugettext_lazy
在 v2.2 中已弃用,并且在 django v3+ 中不再使用。检查您的 Django 文档有关延迟翻译的版本,您可以尝试:The
i
at the end of the files extension means that the file is aninterface
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:有两种简单的方法可以
其他目录中复制该行或功能或类
从
我明白了,
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
如图所示,实际上,VSCODE告诉我们,此处的导入文件已经是错误的文件,并且该文件不包括在此软件包中。如上所述,如果无法确保导入的内容,则可以使用“*”。
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.