Also versuche ich Django zu lernen, indem ich das Tutorial-Programm modifiziere, das ist übrigens Version 1.9.Einstellen der Position von Django Templates
Ich habe meinen Projektordner, genannt Schlamm, und dann meinen App-Ordner, Abstimmungen. In der Umfragen-App gibt es einen Vorlagenordner, der dann zurück zum Umfragen-Ordner kreist. Wenn ich eine Vorlage erstellen möchte, lege ich sie einfach dort hin. Ich wollte auch eine Vorlage für meine Haupt-Homepage erstellen, die außerhalb der Umfragen sein würde.
Ich habe versucht, einen Vorlagenordner innerhalb des Basis-MUD-Ordners sowie des Mud/Mud-Ordners zu erstellen, und keiner funktioniert. Ich bekomme immer den Fehler, wenn es für die index.html von ...
Django suchen versucht, diese Vorlagen Laden, in dieser Reihenfolge:
Mit Motor django: django.template.loaders.app_directories.Loader: /home/andaib/themudreport.com/env/lib/python2.7/site-packages/django/contrib/admin/templates/mud/index.html (Quelle existiert nicht) django.template.loaders.app_directories.Loader : /home/andaib/themudreport.com/env/lib/python2.7/site-packages/django/contrib/auth/templates/mud/index.html (Quelle existiert nicht) django.template.loaders.app_directories. Loader: /home/andaib/themudreport.com/mud/polls/templates/mud/index.html (Quelle existiert nicht)
Es scheint nur in den Schlamm/Umfragen zu suchen ... für einen Schlamm/Umfragen/Schlamm.
Dies scheint mir verrückt, unorganisiert, und ich bin sicher, es muss eine Möglichkeit geben, um die Liste der Ordner hinzufügen, die ich für Vorlagen zugreifen möchte, aber innerhalb meiner settings.py finde ich es nicht . Vielleicht kann jemand helfen? Das fühlt sich an wie eine 2-Sekunden-Reparatur für jemanden, der mehr Erfahrung mit Django hat.
"""
Django settings for mud project.
Generated by 'django-admin startproject' using Django 1.9.4.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=gc!jwa)#q%8t&cl^wi3ago!=dq)ws)[email protected]'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
]
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mud.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 = 'mud.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '*****',
'USER': '*****',
'PASSWORD': '*****',
'HOST': '*****',
'PORT': '*****',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.9/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/1.9/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.dirname(BASE_DIR) + '/public/static/'
Ich habe bereits die TEMPLATE_DIRS-Liste in Zeile 28, muss ich auch die TEMPLATES-Liste löschen? – firestreak
Danke euch beiden, eine Kombination aus Ihrer Antwort und seiner Antwort! Die Templates-Liste gelöscht, wie du es gesagt hast, und den Join dem Join hinzugefügt, wie er es getan hat. – firestreak