Используя URLconf, определенный в ''.urls, Django попробовал эти шаблоны URL, в таком порядке:
Сначала я знаю, что это обычный вопрос. Но я не могу разобраться в нем.
У меня есть приложение с именем main. и у меня есть в основном фордере папка templates и основная папка. и в этой папке у меня есть все html шаблоны, например home.html.
Итак, html-страница home.html выглядит следующим образом:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
TEST PAGE
</body>
</html>
и мой views.py:
def home(request):
return render(request, "main/home.html")
и urls.py в main:
path('', views.home),
urls.py:
path('main/', include('main.urls')),
и settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
]
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
STATIC_ROOT = 'C:\\static_files_cdbn'
Но если я перейду к:
http://127.0.0.1:8000/main/home
или http://127.0.0.1:8000/home
Я просто получаю эту ошибку:
Using the URLconf defined in schoolfruitnvwa.urls, Django tried these URL patterns, in this order:
admin/
main/ [name='index']
main/
The current path, main/home, didn’t match any of these.
Вопрос. Как с этим бороться?