我正在尝试在我的django项目中创建应用程序。我在虚拟环境中遇到了这个错误。但是,如果我尝试使用虚拟环境创建应用程序,它可以正常工作
(venv)subhash@mordor:~/backend/backend$ django-admin startapp vehicles
Traceback (most recent call last):
File "/home/subhash/backend/venv/bin/django-admin", line 11, in <module>
sys.exit(execute_from_command_line())
File "/home/subhash/backend/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/subhash/backend/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/home/subhash/backend/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/home/subhash/backend/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/home/subhash/backend/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named backend.settings.dev
后端是我的项目名称。
我的dev.py文件
from backend.settings.common import *
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1']
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'tech',
'PASSWORD': 'tech',
'HOST': 'localhost',
'PORT': '5432',
}
}
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
答案 0 :(得分:-1)
尝试:
django-admin.py startapp vehicles