前提・実現したいこと
django初学者です。
「動かして学ぶ! Python Django開発入門」という書籍を見ながら、
djangoを使ってWEBアプリケーションを作成しようとしています。
各種WEBページとDBの設定等完了したつもりで、TestCaseクラスとSeleniumを使ったテストコードを作成して、
すべてのプロジェクトのテストを実施したのですが、以下の3件のエラーの修正箇所がわからず、お力添え頂けますでしょうか。
(仮想環境) 最上位のプロジェクトディレクトリ>python manage.py test
System check identified no issues (0 silenced).
DevTools listening on ws://127.0.0.1:53911/devtools/browser/5677e94c-b138-4742-9f6e-ca3a8e2edba5
EEE
ERROR: test_login (accounts.tests.TestLogin)
Traceback (most recent call last):
File "最上位のプロジェクトディレクトリ\accounts\tests.py", line 18, in test_login
self.selenium.get('http://localhost:8000' + str(reverse_lazy('account_login')))
File "仮想環境のパス\lib\site-packages\django\utils\functional.py", line 140, in __text_cast
return func(*self.__args, **self._kw)
File "仮想環境のパス\lib\site-packages\django\urls\base.py", line 30, in reverse
resolver = get_resolver(urlconf)
File "仮想環境のパス\lib\site-packages\django\urls\resolvers.py", line 70, in get_resolver
urlconf = settings.ROOT_URLCONF
File "仮想環境のパス\lib\site-packages\django\conf_init.py", line 83, in getattr
val = getattr(self.wrapped, name)
File "仮想環境のパス\lib\site-packages\django\conf_init.py", line 239, in getattr
return getattr(self.default_settings, name)
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'
======================================================================
ERROR: test_login (accounts.tests.TestLogin)
Traceback (most recent call last):
File "仮想環境のパス\lib\site-packages\django\test\testcases.py", line 284, in _setup_and_call
self._post_teardown()
File "仮想環境のパス\lib\site-packages\django\test\testcases.py", line 1006, in _post_teardown
self._fixture_teardown()
File "仮想環境のパス\lib\site-packages\django\test\testcases.py", line 1038, in fixture_teardown
call_command('flush', verbosity=0, interactive=False,
File "仮想環境のパス\lib\site-packages\django\core\management_init.py", line 181, in call_command
return command.execute(*args, **defaults)
File "仮想環境のパス\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "仮想環境のパス\lib\site-packages\django\core\management\commands\flush.py", line 47, in handle
sql_list = sql_flush(self.style, connection,
File "仮想環境のパス\lib\site-packages\django\core\management\sql.py", line 9, in sql_flush
tables = connection.introspection.django_table_names(only_existing=True, include_views=False)
File "仮想環境のパス\lib\site-packages\django\db\backends\base\introspection.py", line 99, in django_tab
le_names
existing_tables = set(self.table_names(include_views=include_views))
File "仮想環境のパス\lib\site-packages\django\db\backends\base\introspection.py", line 50, in table_name
s
with self.connection.cursor() as cursor:
File "仮想環境のパス\lib\site-packages\django\utils\asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "仮想環境のパス\lib\site-packages\django\db\backends\base\base.py", line 259, in cursor
return self._cursor()
File "仮想環境のパス\lib\site-packages\django\db\backends\dummy\base.py", line 20, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE va
lue. Check settings documentation for more details.
======================================================================
ERROR: diary.tests.test_views (unittest.loader._FailedTest)
ImportError: Failed to import test module: diary.tests.test_views
Traceback (most recent call last):
File "C:\Users\mamam\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "C:\Users\mamam\AppData\Local\Programs\Python\Python39\lib\unittest\loader.py", line 377, in get_module_from
name
import(name)
File "最上位のプロジェクトディレクトリ\diary\tests\test_views.py", line 5, in <module>
from ..models import Diary
File "最上位のプロジェクトディレクトリ\diary\models.py", line 1, in <module>
from accounts.models import CustomUser
File "最上位のプロジェクトディレクトリ\accounts\models.py", line 1, in <module>
from django.contrib.auth.models import AbstractUser
File "仮想環境のパス\lib\site-packages\django\contrib\auth\models.py", line 5, in <module>
from django.contrib.contenttypes.models import ContentType
File "仮想環境のパス\lib\site-packages\django\contrib\contenttypes\models.py", line 133, in <module>
class ContentType(models.Model):
File "仮想環境のパス\lib\site-packages\django\db\models\base.py", line 113, in new
raise RuntimeError(
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and is
n't in an application in INSTALLED_APPS.
Ran 2 tests in 6.600s
FAILED (errors=3)
試したこと
エラーコードに書かれている、編集した箇所を見返してみたのですが、記述ミスはなさそうでした、、
ツール
Python 3.9.1
PostgreSQL 10
PyCharm Community Edition 2021.1.2
あなたの回答
tips
プレビュー