我是Java的新手。我得到了我認爲嘗試在Pycharm項目中使用Django類的類路徑問題。我如何讓我的項目識別django.contrib.auth.models包?如何使用Pycharm來檢查使用Django和docker-compose的測試?
以下是錯誤消息我得到:
/usr/bin/python /Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 49963 --file /Users/tcl/_myproject/workspace/myprojectapi/django-nonrel/myproject/integration_tests/tests/bulk_import_validation.py
pydev debugger: process 4747 is connecting
Connected to pydev debugger (build 172.3317.103)
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1596, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1023, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/tcl/_myproject/workspace/myprojectapi/django-nonrel/myproject/integration_tests/tests/bulk_import_validation.py", line 1, in <module>
from django.contrib.auth.models import User
ImportError: No module named django.contrib.auth.models
Process finished with exit code 1
我得到這個錯誤試圖通過對類右擊並選擇調試運行在Pycharm一個測試類。
測試通常由使用該CMD線運行:
搬運工-撰寫運行myproject_api蟒manage.py測試integration_tests --configuration =開發。
有沒有辦法使用Pycharm調試器來逐步通過此代碼?
你們是不是要直接從Django項目運行的腳本?有一個'manage.py'可以幫助你運行你的項目。 –
我正在運行,右鍵單擊PyCharm中的test.py文件並選擇Debug。 – John