2017-07-02 10 views
0

Nachdem ich mein django Projekt von meinem lokalen Rechner zu einem Remote-Server hochgeladen dieser Fehler erscheintDjango TemplateDoesNotExist Fehler

TemplateDoesNotExist at/

registration/login.html 

Request Method: GET Request URL: http://ip:8000/ Django Version: 1.8.6 Exception Type: TemplateDoesNotExist Exception Value: 

registration/login.html 

Exception Location: /home/market/local/lib/python2.7/site-packages/django/template/loader.py in get_template, line 46 Python Executable: /home/market/bin/python Python Version: 2.7.12 Python Path: 

['/home/market/src', '/home/market/lib/python2.7', '/home/market/lib/python2.7/plat-x86_64-linux-gnu', '/home/market/lib/python2.7/lib-tk', '/home/market/lib/python2.7/lib-old', '/home/market/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/home/market/local/lib/python2.7/site-packages', '/home/market/lib/python2.7/site-packages'] 

Server time: Sun, 2 Jul 2017 08:35:49 +0000 

und dieser Fehler wird in django Serverkonsole

(1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG. 

TEMPLATE in Einstellungen

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [os.path.join(BASE_DIR, 'templates')], 
     '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', 
      ], 
     }, 
    }, 
] 

Settings.py

""" 
Django settings for blackmarket project. 

Generated by 'django-admin startproject' using Django 1.8.6. 

For more information on this file, see 
https://docs.djangoproject.com/en/1.8/topics/settings/ 

For the full list of settings and their values, see 
https://docs.djangoproject.com/en/1.8/ref/settings/ 
""" 

# Build paths inside the project like this: os.path.join(BASE_DIR, ...) 
import os 

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.8/howto/deployment/checklist/ 

# SECURITY WARNING: keep the secret key used in production secret! 
SECRET_KEY = 'ijpwl*f+r5ewyo6-3eorp)&natbb7nh5oh13h&wllhb0o#)gxu' 

# SECURITY WARNING: don't run with debug turned on in production! 
DEBUG = True 

ALLOWED_HOSTS = [] 



TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth", 
    "django.core.context_processors.debug", 
    "django.core.context_processors.i18n", 
    "django.core.context_processors.media", 
    "django.core.context_processors.request", 
    "django.core.context_processors.static", 
) 




# Application definition 

INSTALLED_APPS = (
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 
    'products', 
) 

MIDDLEWARE_CLASSES = (
    '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', 
    'django.middleware.security.SecurityMiddleware', 
) 

ROOT_URLCONF = 'blackmarket.urls' 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [os.path.join(BASE_DIR, 'templates')], 
     '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 = 'blackmarket.wsgi.application' 


# Database 
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', 
     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 
    } 
} 


# Internationalization 
# https://docs.djangoproject.com/en/1.8/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.8/howto/static-files/ 

STATIC_URL = '/static/' 

STATICFILES_FINDERS = (
    "django.contrib.staticfiles.finders.FileSystemFinder", 
    "django.contrib.staticfiles.finders.AppDirectoriesFinder", 
) 
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"), 
) 


# login redirect 
LOGIN_REDIRECT_URL = '/detail' 
LOGIN_URL = '/login/' 
LOGOUT_URL = '/logout/' 
+0

Wie lautet der Pfad zu der Vorlage, die geladen werden soll und was haben Sie in settings.py, die mit 'TEMPLATE_' beginnen? – Melvyn

+0

Also gibt es eine Datei '/ home/market/src/templates/registration/login.html'? (und bitte schauen Sie auf den Remote-Server :)) – Melvyn

+0

Nein, gibt es /home/market/src/templates/login.html – Louis

Antwort

0

Sie haben eine der folgenden Situationen:

  • Sie bereitgestellt haben, die Dateien aus templates/registration auf Ihrem lokalen Rechner zu /home/market/src/templates statt /home/market/src/templates/registration.
  • Das gleiche Problem besteht auf dem lokalen Rechner

Also Sie brauchen, um herauszufinden, welches es ist und entsprechend anpassen, indem entweder das registration Verzeichnis unter templates/ Erstellen und dort die Dateien oder den Code ändern bewegen, die für Anrufe registration/login.html zu verwenden login.html.

+0

in meinem localhost funktioniert es gut, und ich nie einen Ordner namens/Registrierung/!! – Louis

+0

Ich habe einen Ordner 'Registrierung' erstellt, als ich HTML-Dateien darin verschoben habe und es funktioniert !! Ich habe keine Ahnung, welcher Codecode diesen Ordner aufruft! Danke @ Melvyn – Louis

+0

Es kann in der Datenbank sein. Verwenden Sie eine App für die Anmeldung/Registrierung? – Melvyn

Verwandte Themen