bitte kann mir jemand helfen ich kann nicht herausfinden, was ist der Fehler beim Rendern Vorlage in Djano 2.0 ich erstellte eine App und und in der views.py Abschnitt fügte ich alle thoe Codezeilen von manange .py importiert Urls (direkt in den Ansichten) versucht, den Server (python views.py runserver)Vorlage existiert nicht "Django 2.0"
hier ist meine komplette Code aus views.py
import os
import sys
from django.conf import settings
DEBUG = os.environ.get('DEBUG', 'on') == 'on'
SECRET_KEY = os.environ.get('SECRET_KEY', os.urandom(32))
ALLOWED_HOSTS = os.environ.get('localhost','127.0.0.1').split(',')
BASE_DIR = os.path.dirname(__file__)
settings.configure(
DEBUG=DEBUG,
SECRET_KEY=SECRET_KEY,
ALLOWED_HOSTS=ALLOWED_HOSTS,
ROOT_URLCONF=__name__,
MIDDLEWARE_CLASSES=(
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
),
)
INSTALLED_APPS=(
'django.contrib.staticfiles',
'django.contrib.contenttypes',
'django.contrib.auth',
),
TEMPLATE_DIRS=(
os.path.join(BASE_DIR, 'templates'),
),
STATICFILES_DIRS=(
os.path.join(BASE_DIR, 'static'),
),
STATIC_URL='/static/',
#############################views & urls###############################s
from django import forms
from django.urls import path,include
from django.core.cache import cache
from django.core.wsgi import get_wsgi_application
from django.http import HttpResponse, HttpResponseBadRequest
from django.shortcuts import render
from django.views.decorators.http import etag
# Create your views here.
application = get_wsgi_application()
def home(request):
return render(request,'index.html')
urlpatterns=[
path('',home,name='home'),
]
###################################### #############################################
if __name__ == "__main__":
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
zu laufen und ich versuchte, Vorlagen in der gleichen Platzierung Verzeichnis, in dem Ansichten vorhanden sind und auch außerhalb des App-Ordners
soll ich eine grundlegende Vorlage bekommen, wie im Buch leichten django
stattdessen erklärt:
TemplateDoesNotExist at/
index.html
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.0
Exception Type: TemplateDoesNotExist
Exception Value:
index.html
Exception Location: C:\Users\madhumani\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\template\loader.py in get_template, line 19
Python Executable: C:\Users\madhumani\AppData\Local\Programs\Python\Python36-32\python.exe
Python Version: 3.6.2
Python Path:
['D:\\python\\tempo python\\dajngo rest api\\api\\pi',
'C:\\Users\\madhumani\\AppData\\Local\\Programs\\Python\\Python36-32\\python36.zip',
'C:\\Users\\madhumani\\AppData\\Local\\Programs\\Python\\Python36-32\\DLLs',
'C:\\Users\\madhumani\\AppData\\Local\\Programs\\Python\\Python36-32\\lib',
'C:\\Users\\madhumani\\AppData\\Local\\Programs\\Python\\Python36-32',
'C:\\Users\\madhumani\\AppData\\Roaming\\Python\\Python36\\site-packages',
'C:\\Users\\madhumani\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages']