我是python,django和mongoDB世界的新手。我設置的Django項目(VIRTUALENV,Python3,Django的== 1.10.1的MongoDB),並安裝了一些基本的程序包要求:如何在Django Framework和Python3中使用MongoDB
Django==1.10.1
django-mongodb-engine==0.6.0
djangotoolbox==1.8.0
mongoengine==0.9.0
pymongo==3.3.0
但是當我試圖用python3 manage.py syncdb
來執行syncdb,那麼它顯示
~/virtenv/lib/python3.5/site-packages/django_mongodb_engine/base.py", line 272
raise ImproperlyConfigured, exc_info[1], exc_info[2]
^
SyntaxError: invalid syntax
Settings.py
import os
import mongoengine
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
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',
]
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 = 'fvp_amu.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 = 'fvp_amu.wsgi.application'
# Database
DATABASES = {
'default' : {
'ENGINE' : '',
'NAME' : 'fvp_amu'
}
}
# Password validation
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',
},
]
STATIC_URL = '/static/'
請添加您的settings.py。 – Windsooon
我已經添加了setting.py @Windso –