0
以前完美正常工作,剛剛放棄了我。當使用任何類型manage.py
命令像下面,我看到Performing system checks...
Django manage.py命令掛起
python manage.py runserver
或
python manage.py makemigrations
約懸掛的30-60秒後,我再拿到:
System check identified no issues (0 silenced).
哪掛起並掛起和掛起...然後大約6分鐘後,我再次看到正常的Quit the server with CONTROL-C
要調試此問題,我甚至試圖評論我的應用程序和中間件,以及關閉我的PY上的其他應用程序並執行重新啓動,仍然沒有改變。我還需要看看這個呢?這似乎太長了。
settings.py
import os
import logging
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SITE_ROOT = os.path.realpath(os.path.dirname(os.path.abspath(__file__)))
print ("SITE_ROOT: {0}".format(SITE_ROOT))
print ("BASE_DIR: {0}".format(BASE_DIR))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'blah'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'user_auth',
#'users',
]
#Handle session is not Json Serializable
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
#Parameters for setting the expiry
SESSION_SAVE_EVERY_REQUEST = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 10
LDAP_SERVER = '10.253.8.31'
LDAP_AUTH_SEARCH_BASE = "ou=Konzern, dc=compnayx, dc=de" # The LDAP search base for looking up users.
DOMAIN_NAME = 'MyDomain'
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
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',
#'UserAuth.Middleware.ldap_interface.LDAP_Auth_Backend',
]
# Auto logout delay in minutes
AUTO_LOGOUT_DELAY = 1 #equivalent to 1 minutes
ROOT_URLCONF = 'UserAuth.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 = 'UserAuth.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/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',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = False # Does not assume timestamps in DB are all in UTC
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
ADMINS = (
('me', 'myemail'),
)
MAILER_LIST = ['myemail'] # To whom shall the mail be sent
EMAIL_HOST = 'smtp-mail.outlook.com'
EMAIL_HOST_USER = 'another_email' # We're sending the notification from here so we need HOST, PW, PORT
EMAIL_HOST_PASSWORD = 'my_password'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = 'myemail'
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'standard': {
'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
},
},
'handlers': {
'default': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': SITE_ROOT + '\\logfile.log',
'maxBytes': 1024*1024*5, # 5 MB
'backupCount': 5,
'formatter':'standard',
},
'request_handler': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': SITE_ROOT + '\\django_request.log',
'maxBytes': 1024*1024*5, # 5 MB
'backupCount': 5,
'formatter':'standard',
},
'mail_admins': {
'level': 'DEBUG',
'class': 'django.utils.log.AdminEmailHandler',
},
},
'loggers': {
'': {
'handlers': ['mail_admins', 'default'],
'level': 'DEBUG',
'propagate': True
},
'django.request': {
'handlers': ['request_handler'],
'level': 'DEBUG',
'propagate': False
},
'django': {
'handlers': ['request_handler', 'default', 'mail_admins'],
'level': 'DEBUG',
'propagate': True,
},
}
}