Django render не открывает html страницу
view
def file_upload(request):
if request.method == 'POST':
print('я тут post')
return render(request, 'files.html', {})
else:
print('я тут get')
return render(request, 'files.html', {})
urls
urlpatterns = [
path('', views.dropzone_uploads),
path('fileupload/', views.file_upload),
]
командная строка
[09/Jun/2021 01:04:48] "GET /upload/ HTTP/1.1" 200 3307
я тут post
[09/Jun/2021 01:04:52] "POST /upload/fileupload/ HTTP/1.1" 200 9
files.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="fileupload/" method="POST">
{% csrf_token %}
<input type="submit" value="Submit" />
</form>
</body>
</html>
т.е тело view выполняется, а return render нет.
Ответы (1 шт):
Автор решения: paqstd
→ Ссылка
Возможно вы не указали приложение в INSTALLED_APPS в файле settings.py:
INSTALLED_APPS = [
...
'core'
]
Либо можете указать папку для шаблона в TEMPLATES:
TEMPLATES = [
{
...
'DIRS': [
BASE_DIR / 'templates'
],
}
]
Так же можно подробно изучить основы Django.
