Django modules errors and tests
I have some problems with Django. My application works fine but my IDE (Pycharm) considers it a mistake. To be clear all of the applications are added to INSTALLED_APPS in settings.py enter image description here
For example:
**And when I run the command **
> py manage.py test
I am getting a list of errors in every application. I haven't written any tests. Even when I am adding some simple test like this:
from django.test import TestCase
class TestSimpleComponent(TestCase):
def test_basic_sum(self):
assert 1+1 == 2
It doesn't work and the output is still the same.
Found 10 test(s). System check identified no issues (0 silenced). EEEEEEEEEE ====================================================================== ERROR: myshop.accounts (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.accounts Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.accounts'
====================================================================== ERROR: myshop.api (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.api Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.api'
====================================================================== ERROR: myshop.cart (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.cart Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.cart'
====================================================================== ERROR: myshop.coupons (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.coupons Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.coupons'
====================================================================== ERROR: myshop.myshop (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.myshop Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.myshop'
====================================================================== ERROR: myshop.order (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.order Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.order'
====================================================================== ERROR: myshop.payment (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.payment Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.payment'
====================================================================== ERROR: myshop.shop (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.shop Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.shop'
====================================================================== ERROR: myshop.shop_info (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.shop_info Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.shop_info'
====================================================================== ERROR: myshop.shopcontact (unittest.loader._FailedTest)
ImportError: Failed to import test module: myshop.shopcontact Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 470, in _find_test_path package = self._get_module_from_name(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\unittest\loader.py", line 377, in _get_module_from_name import(name) ModuleNotFoundError: No module named 'myshop.shopcontact'
Ran 10 tests in 0.001s
FAILED (errors=10)
I would like to fixed the error when I am running
py manage.py test
This is my file structure
When I am trying to run only this one test using Django I am getting this error
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Ran 0 tests in 0.004s
FAILED (errors=1)