I am very new to python and when I run the
我是python的新手,当我运行时
$ python manage.py collectstatic
$ python manage.py collectstatic
command, It returns
命令,它返回
'unknown command: 'collectstatic''
'未知命令:'collectstatic''
From what I have found from research there seems to be a problem with settings.py, here is my settings.py:
根据我从研究中发现的,settings.py似乎存在问题,这是我的settings.py:
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'basic_code.sqlite3',
# The following settings are not used with sqlite3:
'USER': '',
'PASSWORD': '',
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
ALLOWED_HOSTS = []
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static/media')
MEDIA_URL = '/media'
STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static/static-only')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static/static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'XXXXXXXXXX'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'basic_code.urls'
WSGI_APPLICATION = 'basic_code.wsgi.application'
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static/templates'),
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'contact',
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
Thank you so much! I really appreciate any help.
非常感谢!我非常感谢任何帮助。
1 个解决方案
#1
8
Change media url from /media to /media/
将媒体网址从/ media更改为/ media /
Next time if you encounter such a problem, try runserver and check trace if it does not work.
下次如果遇到这样的问题,请尝试运行runserver并检查跟踪是否不起作用。
#1
8
Change media url from /media to /media/
将媒体网址从/ media更改为/ media /
Next time if you encounter such a problem, try runserver and check trace if it does not work.
下次如果遇到这样的问题,请尝试运行runserver并检查跟踪是否不起作用。