python - Unknown command: 'collectstatic' Django 1.7 -
i want static files. use django 1.7 , python 2.7.5 , openshift hosting. when try run:
python manage.py collectstatic
i get:
unknown command: 'collectstatic' type 'manage.py help' usage.
in 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/' ...
many people had proble. forgot 'django.contrib.staticfiles' in installed_apps. have setting.
ok, run help:
options: -v verbosity, --verbosity=verbosity verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output --settings=settings python path settings module, e.g. "myproject.settings.main". if isn't provided, django_settings_module environment variable used. --pythonpath=pythonpath directory add python path, e.g. "/home/djangoprojects/myproject". --traceback raise on exception --no-color don't colorize command output. --version show program's version number , exit -h, --help show message , 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 - environment variable (link: https://www.openshift.com/page/openshift-environment-variables) can me?
it looks can't find environment variable openshift_app_name
. should try setting , see if fixes problem. django can't import settings because can't find environment variable.
those environment variables set openshift. running collectstatic command in shell has not had them set. you'll either need set them in shell or edit settings.py able handle situation. work:
databases = { 'default': { 'engine': 'django.db.backends.mysql', 'name': os.environ.get('openshift_app_name', 'a sensible default'),
Comments
Post a Comment