我想要做靜態文件。我使用Django 1.7和Python 2.7.5以及openshift託管。當我嘗試運行:未知命令:'collectstatic'Django 1.7
python manage.py collectstatic
我得到:
Unknown command: 'collectstatic' Type 'manage.py help' for usage.
在我的settings.py:
...
INSTALLED_APPS = (
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'testapp',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.static',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': os.environ['OPENSHIFT_APP_NAME'],
'USER': os.environ['OPENSHIFT_MYSQL_DB_USERNAME'],
'PASSWORD': os.environ['OPENSHIFT_MYSQL_DB_PASSWORD'],
'HOST': os.environ['OPENSHIFT_MYSQL_DB_HOST'],
'PORT': os.environ['OPENSHIFT_MYSQL_DB_PORT'],
}
}
STATIC_ROOT = ''
STATIC_URL = '/static/'
...
很多人有這個proble。他們在INSTALLED_APPS中忘記了'django.contrib.staticfiles'。但我有這個設置。
好吧,我跑的幫助:
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
--settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Raise on exception
--no-color Don't colorize the command output.
--version show program's version number and exit
-h, --help show this help message and exit
Traceback (most recent call last):
...
File "c:\Python27\lib\os.py", line 423, in __getitem__
return self.data[key.upper()]
KeyError: 'OPENSHIFT_APP_NAME'
OPENSHIFT_APP_NAME - 環境變量(鏈接:https://www.openshift.com/page/openshift-environment-variables) 你能幫助我嗎?
謝謝!我做了所有 - 名稱,用戶等,但我得到的錯誤: ImportError:無法導入設置'testapi.settings.INSTALLED_APPS'(是否在sys.path?設置文件中是否有導入錯誤?):沒有名爲INSTALLED_APPS的模塊 –
這意味着你已經破壞了你的settings.py文件...... – aychedee
好吧,我會發現我的錯誤。 再次 - 感謝您的幫助 –