模板ID将Oscar软件包移至我的应用程序后不起作用?

时间:2019-08-07 11:11:50

标签: django django-models django-rest-framework django-templates django-oscar

我的主页上出现404错误,我只是将Django Oscar软件包移至我的应用程序,但现在无法正常工作,在移至我的应用程序之前,它运行良好,请让我知道这是什么问题。 每当我打开网站时,它就会向我显示错误404,我认为urls.py文件中存在一些错误 这是我的settings.py文件...

"""
Django settings for frobshop project.

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

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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
from oscar.defaults import *
location = lambda x: 
os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', x)
PROJECT_DIR=os.path.dirname(__file__)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = 
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

SECRET_KEY = 'bg-a-t#7--wbz$rie*2n%1c-9j#0v8own&5+t7^kduqzc&j5nm'
DEBUG = True

ALLOWED_HOSTS = []


# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'compressor',
'widget_tweaks',
'haystack',
'treebeard',
'sorl.thumbnail',
'django_tables2',
#'south',
#oscar apps
'oscar',
'oscar.apps.analytics',
'oscar.apps.checkout',
'oscar.apps.address',
'oscar.apps.shipping',
'oscar.apps.catalogue',
'oscar.apps.catalogue.reviews',
'oscar.apps.partner',
'oscar.apps.basket',
'oscar.apps.payment',
'oscar.apps.offer',
'oscar.apps.order',
'oscar.apps.customer',
'oscar.apps.search',
'oscar.apps.voucher',
'oscar.apps.wishlists',
'oscar.apps.dashboard',
'oscar.apps.dashboard.reports',
'oscar.apps.dashboard.users',
'oscar.apps.dashboard.orders',
'oscar.apps.dashboard.catalogue',
'oscar.apps.dashboard.offers',
'oscar.apps.dashboard.partners',
'oscar.apps.dashboard.pages',
'oscar.apps.dashboard.ranges',
'oscar.apps.dashboard.reviews',
'oscar.apps.dashboard.vouchers',
'oscar.apps.dashboard.communications',
'oscar.apps.dashboard.shipping',

 ] 

SITE_ID = 1

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'oscar.apps.basket.middleware.BasketMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
 ]
AUTHENTICATION_BACKENDS = (
'oscar.apps.customer.auth_backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
 )
EMAIL_BACKEND= 'django.core.mail.backends.console.Emailbackend'

ROOT_URLCONF = 'oscar.urls'

# from oscar import OSCAR_MAIN_TEMPLATE_DIR
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
        location('templates'), # templates directory of the 
project
    ],
'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',
],
},
},
]

HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
},
}


TEMPLATE_CONTEXT_PROCESSORS = (
 "django.contrib.auth.context_processors.auth",
 "django.core.context_processors.request",
 "django.core.context_processors.debug",
 "django.core.context_processors.i18n",
 "django.core.context_processors.media",
 "django.core.context_processors.static",
 "django.contrib.messages.context_processors.messages",
 'oscar.apps.search.context_processors.search_form',
 # 'oscar.apps.promotions.context_processors.promotions',
 'oscar.apps.checkout.context_processors.checkout',
 'oscar.apps.customer.notifications.context_processors.
  notifications',
 'oscar.core.context_processors.metadata',
   )
 TEMPLATE_DEBUG = True
 WSGI_APPLICATION = 'frobshop.wsgi.application'

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

 HAYSTACK_CONNECTIONS = {
 'default': {
 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
  },
  }

这是我的应用程序urls.py文件。

from django.urls import path, re_path
from . import views
from django.conf.urls.static import static
from django.conf import settings
from django.conf.urls import url, include

urlpatterns = [
    url(r'^i18n/', include('django.conf.urls.i18n')),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0 个答案:

没有答案