我的应用程序配置为使用mysql,但是当我尝试运行时./manage.py迁移此错误ocours
root@renato-VirtualBox:/home/renato/unb-alerta# ./manage.py migrate
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/core/management/__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/renato/unb-alerta/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/renato/unb- alerta/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/renato/unb-alerta/unb_alerta/settings.py", line 139, in <module>
cast=db_url,
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/decouple.py", line 197, in __call__
return self.config(*args, **kwargs)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/decouple.py", line 77, in __call__
return self.get(*args, **kwargs)
File "/home/renato/unb-alerta/venv/lib/python3.5/site- packages/decouple.py", line 64, in get
raise UndefinedValueError('%s option not found and default value was not defined.' % option)
decouple.UndefinedValueError: DATABASE_URL option not found and default value was not defined.
我的.env有DATABASE_URL结束我的settings.py有这个配置
DATABASES = {
'default': config(
'DATABASE_URL',
cast=db_url,
)
}