Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql django平衡-数据库错误_Mysql_Django - Fatal编程技术网

Mysql django平衡-数据库错误

Mysql django平衡-数据库错误,mysql,django,Mysql,Django,我正试图在我的项目中安装django balanced应用程序,但出现了一个错误。 我按照自述文件的说明做了以下工作: #Add to settings import os BALANCED = { 'API_KEY': os.environ.get('BALANCED_API_KEY'), } INSTALLED_APPS = ( ... 'django.contrib.admin', # if you want to use the admin interface

我正试图在我的项目中安装
django balanced
应用程序,但出现了一个错误。 我按照自述文件的说明做了以下工作:

#Add to settings
import os

BALANCED = {
    'API_KEY': os.environ.get('BALANCED_API_KEY'),
}

INSTALLED_APPS = (
   ...
   'django.contrib.admin',  # if you want to use the admin interface
   'django_balanced',
   ...
)


#ran the following on my project root folder
BALANCED_API_KEY=YOUR_API_KEY django-admin.py syncdb #replacing the YOUR_API_KEY with my key
执行此操作时,会出现以下错误:

Traceback (most recent call last):

  File "/usr/local/bin/django-admin.py", line 5, in <module>

    management.execute_from_command_line()

  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line

    utility.execute()

  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command

    klass = load_command_class(app_name, subcommand)

  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class

    module = import_module('%s.management.commands.%s' % (app_name, name))

  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module

    __import__(name)

  File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>

    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal

  File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 9, in <module>

    from django.db import models

  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 11, in <module>

    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:

  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__

    self._setup(name)

  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 46, in _setup

    % (desc, ENVIRONMENT_VARIABLE))

django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. 

您需要设置DJANGO_设置_模块:

You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings

您还可以键入以下命令

BALANCED_API_KEY=YOUR_API_KEY python manage.py syncdb
显示您的设置同样,您是否已设置为
mysite.settings
这是必需的设置
BALANCED_API_KEY=YOUR_API_KEY python manage.py syncdb