from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'aaa'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'fff.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'fff.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
I created a virtual environment for a new project and installed Django.
When I created the app and ran python manage.py runserver, the following error occurred.
Traceback (most recent call last):
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\commands\runserver.py", line 74, in execute
super().execute(*args, **options)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\base.py", line 448, in execute
output = self.handle(*args, **options)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\commands\runserver.py", line 81, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\conf\__init__.py", line 92, in __getattr__
self._setup(name)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\conf\__init__.py", line 79, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\conf\__init__.py", line 190, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\USER21R16\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'blog'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\fff\manage.py", line 22, in
<module>
main()
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\fff\manage.py", line 18, in
main
execute_from_command_line(sys.argv)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\core\management\base.py", line 415, in run_from_argv
connections.close_all()
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\utils\connection.py", line 84, in close_all
for conn in self.all(initialized_only=True):
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\utils\connection.py", line 76, in all
return [
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\utils\connection.py", line 73, in __iter__
return iter(self.settings)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\utils\connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\db\utils.py", line 148, in configure_settings
databases = super().configure_settings(databases)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\utils\connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\conf\__init__.py", line 92, in __getattr__
self._setup(name)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\conf\__init__.py", line 79, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\USER21R16\OneDrive\바탕 화면\test\tvenv\lib\site-packages\django\conf\__init__.py", line 190, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\USER21R16\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'blog'
I created a new virtual environment, reinstalled python, and deleted and recreated the project, but it didn’t work.
I’m really upset because I couldn’t solve it for a week Help me