问题描述
我的 Django 项目在 本地 PC 和部署后
完美运行请帮我修复!
我面临一些问题:
- 不要显示 Django 错误处理页面。
- Django 管理页面未显示。
my setting & Urls & output File 在这里,我看不到像我的开发一样的 Django 默认。
urls.py 文件
from django.contrib import admin
from django.urls import path,include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('',include('frontend.urls')),path('admin/',admin.site.urls),#path('admission/',include('admission.urls')),path('user/',include('userregistration.urls')),path('study/',include('study.urls')),path('employment/',include('employment.urls')),#path('form/',include('form.urls')),]
urlpatterns = urlpatterns + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
admin.site.index_title = "GSL Adminstrator"
admin.site.index_header = "Global Star Admin"
admin.site.site_title = "Global Star Admin"
admin.site.site_header = "Global Star Admin"
Settings.py 文件
from pathlib import Path,os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'wy7o_s_pw$(71l-ta)0w1fud#7%zm3$5^n2p4ygo$an0n)ieqi'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['dev.globalstar.com.bd','www.dev.globalstar.com.bd']
# Application definition
INSTALLED_APPS = [
'phonenumber_field','dal','dal_select2',# 'grappelli','widget_tweaks','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',#'admission','employment',#'form','frontend','study','travel','hrm','event','dal_queryset_sequence',]
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',]
ROOT_URLCONF = 'gsl.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [
os.path.join(BASE_DIR,'frontend/templates'),os.path.join(BASE_DIR,'userregistration/templates'),'study/templates'),'admission/templates'),'employment/templates'),'form/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 = 'gsl.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
DATABASES = {
'default': {
#'ENGINE': 'django.db.backends.sqlite3',#'NAME': BASE_DIR / 'db.sqlite3','ENGINE': 'django.db.backends.mysql','NAME': 'globalv5_web_app','USER': 'globalv5_gsl_web_app','PASSWORD': 'ky*5q0i3f32U','HOST': 'localhost','PORT': '3306',}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/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/3.1/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/3.1/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR,'userregistration/static'),'study/static'),'employment/static'),'form/static'),'admission/static'),'/home/globalv5/dev.globalstar.com.bd/public/static',]
STATIC_ROOT = os.path.join(BASE_DIR,'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
X_FRAME_OPTIONS = 'ALLOWALL'
XS_SHARING_ALLOWED_METHODS = ['POST','GET','OPTIONS','PUT','DELETE']
和 python manage.py shell
Python 3.8.6 (default,Dec 10 2020,03:32:48)
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help","copyright","credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> settings.DEBUG
True
>>> settings.DEBUG_PROPAGATE_EXCEPTIONS
False
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)