当我运行python manage.py runserver或python manage.py migrate时。我收到这些错误
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 190, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 40, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 14, in <module>
from django.db.migrations.executor import MigrationExecutor
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 6, in <module>
from .loader import MigrationLoader
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 10, in <module>
from django.db.migrations.recorder import MigrationRecorder
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in <module>
class MigrationRecorder(object):
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
class Migration(models.Model):
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 24, in Migration
app = models.CharField(max_length=255)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 1081, in __init__
super(CharField, self).__init__(*args, **kwargs)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 161, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/home/sroy8091/college/local/lib/python2.7/site-packages/django/conf/__init__.py", line 113, in __init__
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
这是我的开发设置
"""
Django settings for kgecweb project.
Generated by 'django-admin startproject' using Django 1.8.
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 = 'my_secret key here'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
#DEBUG = False
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_extensions',
'administration',
'stdimage',
'dept',
'trplc', # Training and Placement app
'faculty',
'student',
'hostels',
'nkn',
'clibrary',
'page',
'contact'
)
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 = 'kgecweb.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 = 'kgecweb.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
#'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.mysql'),
'USER': 'root',
'PASSWORD': '713331',
'HOST': '192.168.33.19',
'PORT': '3306',
#'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATICFILES_DIRS = (os.path.join(BASE_DIR, "../static"),)
#STATIC_ROOT= os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, '../media')
MEDIA_URL = '/media/'
我也用sql命令初始化数据库,而密钥在这里也不是空的。虽然它继续说。我不知道如何解决这个问题。 这是我的项目目录
我甚至尝试制作settings.py文件,然后也会出现此错误。
答案 0 :(得分:2)
然后尝试:
python manage.py runserver --settings=kgecweb.settings.development
我猜您没有使用内置的setting.py或者您重命名它或创建一个目录来处理不同的settings.py。
确保您的项目在您的python路径中,使用它来查找。
import sys
print(sys.path)
或者你可以在kgecweb(应用程序)中创建一个settings.py然后运行
python manage.py runserver
如果有效,请尝试:
python manage.py runserver --settings=kgecweb.settings.development
答案 1 :(得分:0)
从vanilla settings.py
中,您可以通过设置环境变量来指定要使用的设置来指定要执行的设置。例如。
假设你的settings.py中有一个名为DJANGO_ENV ='prod'的env变量
import os
environment = os.environ.get('DJANGO_ENV', 'dev')
if environment == 'prod':
from project_folder.production_settings import *
else:
from project_folder.development_settings import *
#rest of code
答案 2 :(得分:0)
您拼写错误文件的名称。
更改
development.py
到
string script = "document.getElementsByClassName('ITLCover')[0].remove();";
((IJavaScriptExecutor) Driver.WebDriver).ExecuteScript(script);
并且一切都应该直接调用文件