在django中创建新应用程序时获取无效语法

时间:2015-01-20 00:06:58

标签: python django python-3.x

我已经安装了Django,我尝试创建一个新的应用程序,但我收到此消息,我不明白为什么......

这是我的终端显示的内容

#>python manage.py startapp backoffice
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management    /__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py",  line 46, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 94, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/antares/fensalir/fensalir/settings.py", line 64
LANGUAGE_CODE = 'fr-fr'
              ^
SyntaxError: invalid syntax

这是我的settings.py

DEBUG = True

TEMPLATE_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_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',
 )

ROOT_URLCONF = 'fensalir.urls'

WSGI_APPLICATION = 'fensalir.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Internationalization
#        'OPTIONS' : { "init_command": "SET foreign_key_checks = 0;" },#     https://docs.djangoproject.com/en/1.7/topics/i18n/
    'NAME': 'xxxxx',
     LANGUAGE_CODE = 'fr-fr'
    'USER': 'xxx',
    TIME_ZONE = 'Europe/Paris'
    'PASSWORD': 'xxx',
    USE_I18N = True
    'HOST': 'mysql.xxxxxx',
    USE_L10N = True
    'PORT': '',
    USE_TZ = True
}

# Static files (CSS, JavaScript, Images) https://docs.djangoproject.com /en/1.7/howto/static-files/
}
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_DIRS = (
   os.path.join(BASE_DIR, "backoffice/static"),
)

有人能帮助我吗?

1 个答案:

答案 0 :(得分:1)

在定义下一个设置之前,您尚未关闭DATABASES字典。应该是:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'xxxxx',
        'USER': 'xxx',
        'PASSWORD': 'xxx',
        'HOST': 'mysql.xxxxxx',
        'PORT': '',
    }
}

LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True