我正在尝试为已升级到 Django 1.4 的 Django 加载静态内容。该项目已成功部署,但我无法找到该项目的图像和所有静态内容。
请找到 settings.py 文件
# Django settings for DataEntry project.
import sys
import os
from path import path
SETTINGS_FILE_FOLDER = path(__file__).parent.abspath()
sys.path.append(SETTINGS_FILE_FOLDER.joinpath("libs").abspath())
DEBUG = True
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ("127.0.0.1", "localhost", "192.168.100.102")
ADMINS = (
(" Hello World ", "hello.world@gmail.com"),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'gototest', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'root', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'OPTIONS': {
"init_command": "SET storage_engine=INNODB",
}
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Asia/Calcutta'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
#MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER,'static')
MEDIA_ROOT = '/static'
STATIC_PATH = '/static'
UPLOAD_DIR = '/Users/iceman/Documents/gototest/qbank/static/uploads'
SITE_NAME = 'demo.com'
SITE_URL = 'http://alphadev.demo.com'
AUTH_PROFILE_MODULE = 'core.UserProfile'
LOGIN_REDIRECT_URL = '/students/login/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
#STATIC_ROOT = '/Users/iceman/Documents/gototest/qbank/static'
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = ' hidden '
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
# 'django.template.loaders.filesystem.load_template_source',
# 'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
#'utils.XhtmlMortifierMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
#simplCACHE_BACKEND = 'memcached://127.0.0.1:11211/'
ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
SETTINGS_FILE_FOLDER.joinpath("../templates"),
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
TEMPLATE_LOADERS = (
#'django.template.loaders.filesystem.load_template_source',
#'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
AUTHENTICATION_BACKENDS = (
'accounts.backends.EmailOrUsernameModelBackend',
'django.contrib.auth.backends.ModelBackend'
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.sites',
'django.contrib.flatpages',
'core',
'tinymce',
'filebrowser',
'tagging',
'tagging_autocomplete',
'django_extensions',
'registration',
'questionmanager',
'corporate',
)
ADMIN_HASH_SECRET = " "
RECAPTCHA_PUBLIC_KEY = " "
RECAPTCHA_PRIVATE_KEY = " "
SERIALIZATION_MODULES = { 'modeljson' : 'wadofstuff.django.serializers.json' }
SOLR_ROOT = "http://dev.demo.com:8080/QuestionSolr"
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.request",
"django.core.context_processors.i18n",
"utils.context_processor",
"qutils.context_processor",
)
#'plugins': "table,paste,searchreplace,safari,asciimath,contextmenu",
TINYMCE_JS_URL = "/static/tinymce/tiny_mce/tiny_mce.js"
TINYMCE_JS_ROOT ="/static/tinymce/tiny_mce"
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,asciimath,gototest,indicime",
'mode' : "textareas",
'theme': "advanced",
'cleanup_on_startup': True,
'custom_undo_redo_levels': 10,
'theme_advanced_buttons1' : "fontselect,fontsizeselect,formatselect,bold,italic,underline,strikethrough,separator,sub,sup,separator,cut,copy,paste,undo,redo",
'theme_advanced_buttons2' : "justifyleft,justifycenter,justifyright,justifyfull,separator,numlist,bullist,outdent,indent,separator,forecolor",
'theme_advanced_buttons3' : "gototest,backcolor,separator,hr,link,unlink,image,table,code,separator,asciimath,asciimathcharmap,indicime",
'theme_advanced_fonts' : "Arial=arial,helvetica,sans-serif,Courier New=courier new,courier,monospace,Georgia=georgia,times new roman,times,serif,Tahoma=tahoma,arial,helvetica,sans-serif,Times=times new roman,times,serif,Verdana=verdana,arial,helvetica,sans-serif",
'theme_advanced_toolbar_location' : "top",
'theme_advanced_toolbar_align' : "left",
'theme_advanced_statusbar_location' : "bottom",
'tab_focus' : ':prev,:next',
}
#'content_css' : "/static/css/content.css",
TINYMCE_SPELLCHECKER = False
TINYMCE_COMPRESSOR = True
FORCE_LOWERCASE_TAGS = True
MARKITUP_FILTER = ('markdown.markdown', {'safe_mode': True})
MARKITUP_SET = 'markitup/sets/markdown'
MARKITUP_SKIN = 'markitup/skins/markitup'
MARKITUP_MEDIA_URL = '/static/'
MARKITUP_AUTO_PREVIEW = True
JQUERY_URL = '/static/js/jquery-1.3.2.min.js'
TAGGING_AUTOCOMPLETE_JS_BASE_URL = "/static"
try:
from local_settings import *
except ImportError: pass
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
当我在浏览器 URL 上查找图像时 =http://127.0.0.1:8000/static/site_img/logo.gif
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/static/site_img/logo.gif
"/Users/iceman/Documents/gototest/qbank/qbank/static/site_img/logo.gif" does not exist