Problem in tests

I have just learned django these days and make a project similar to tutorial.Before i start my project,i copied tutorial code and run,but programe erred when run tests.py(tutorial05),and now it happens again.
I have added my app name in settings.py,and the errors are below:
1.run tests.py

Error
Traceback (most recent call last):
Failure: builtins.tuple: (<class 'django.core.exceptions.ImproperlyConfigured'>, ImproperlyConfigured('Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.'), <traceback object at 0x000001D2BDC66080>)

2.use ‘python manage.py test TA’ in terminal

Found 1 test(s).
System check identified no issues (0 silenced).
E
======================================================================
ERROR: djangoproject.TA (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: djangoproject.TA
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 377, in _get_module_from_name
    __import__(name)
ModuleNotFoundError: No module named 'djangoproject.TA'

How can i solve this problem?Please help!

Can you share your installed_apps setting?

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'appA',
    'TA',
]

I also tried to change ‘TA’ to ‘TA.apps.TAConfig’,but it did’t work too.

Share your project folder structure from root folder

Okay, are you using virtualenv or env or any other environment?
Also what is your OS

win11,i’m using virtualenv download in pycharm,is it result in error?

No
Have you activated virtualenv and which one of the given folder is your virtualenv folder?

I do my project in another computer,how can i judge if my virtualenv is activated?

In your terminal where you are running your command python manage.py runserver there you can see if the environment directory is activated
something like this, here you can see (env) which is my environment folder where everything is installed for this particular project.

jlp-020@jlp020:~/Projects/POC-SingleVendor-BookanAppointment-BE$ source env/bin/activate
(env) jlp-020@jlp020:~/Projects/POC-SingleVendor-BookanAppointment-BE$ 

Note: I’m using ubuntu os, in windows there is different command to activate and even creating a virtualenv

Hi,i think my venv is already activated by pycharm,my terminal prefix shows ‘venv’
(venv) PS C:\Users\user\PycharmProjects\pythonProject\djangoproject>

In addition,i can run python manage.py test TA.tests,but it can’t find my testcase

(venv) PS C:\Users\user\PycharmProjects\pythonProject\djangoproject> python manage.py test TA.tests
Found 0 test(s).
System check identified no issues (0 silenced).
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK

My testcase is below,‘ssex’ is limited CharField(max_length=1)

class StudentModelTest(TestCase):
    def judgesex(self):
        student=Student(sno='001',sname='ggg',sage=23,ssex='Male',sbirth='2000-09-19')
        self.assertIsInstance(student,Student)

When you run your tests, the default behavior of the test utility is to find all the test cases (that is, subclasses of unittest.TestCase) in any file whose name begins with test , automatically build a test suite out of those test cases, and run that suite.

 def test_judgesex(self):
     student=Student(sno='001',sname='ggg',sage=23,ssex='Male',sbirth='2000-09-19')
        self.assertIsInstance(student,Student)