長年のリスナーであり、初めての発信者なので、情報が不足している場合はお知らせください。
現在、Django アプリケーションを実行する AWS EC2 インスタンスがあります。私の現在のタスクは、django-inplaceedit (v 1.4.1) を使用したテーブルでインプレース編集を実行することでした。開発環境では稼働していますが、ステージング/本番環境にデプロイすると、静的 (.js および .css) ファイルが見つかりません。私は Apache サーバーを実行していますが、Django がこれらの静的ファイルを配置した場所を Apache に表示させる方法がわかりません。
他のことに移らなければならないというプレッシャーのため、恥ずかしながらこれらのファイルをアプリの静的フォルダーにコピーし、これを (できれば一時的な修正として) 持っています。
助けてくれてありがとう!: )
PSここに私のapp.confファイルがあります
WSGIScriptAlias / /home/ubuntu/.virtualenvs/sputnik/sputnik_app/sputnik_app/wsgi.py
WSGIPythonPath /home/ubuntu/.virtualenvs/sputnik/sputnik_app:/home/ubuntu/.virtualenvs/sputnik/lib/python2.7/site-packages
<Directory /home/ubuntu/.virtualenvs/sputnik/sputnik_app/sputnik_app>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /media/ /home/ubuntu/.virtualenvs/sputnik/sputnik_app/media/
Alias /static/ /home/ubuntu/.virtualenvs/sputnik/sputnik_app/static/
<Directory /home/ubuntu/.virtualenvs/sputnik/sputnik_app/static>
Require all granted
</Directory>
<Directory /home/ubuntu/.virtualenvs/sputnik/sputnik_app/media>
Require all granted
</Directory>
そして私のsettings.py
"""
Django settings for sputnik_app project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'secret'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
TEMPLATE_DEBUG = False
ALLOWED_HOSTS = ['.mysite.com','.mysite.com.']
ADMINS = ()
MANAGERS = ADMINS
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'sputnik',
'allauth',
'allauth.account',
'bootstrapform',
'bootstrap_toolkit',
'inplaceeditform',
)
ACCOUNT_ADAPTER = "sputnik_app.adapters.SputnikAccountAdapter"
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'sputnik_app.urls'
WSGI_APPLICATION = 'sputnik_app.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'users',
'USER': 'user',
'PASSWORD': 'notactuallymypasswordorisit', #seriously, it's not though
'HOST': '',
'PORT': ''
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'),)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_PATH = os.path.join(BASE_DIR, 'static')
#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
STATIC_PATH,
# STATIC_ROOT,
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# Templates
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
TEMPLATE_CONTEXT_PROCESSORS = (
# Required by `allauth` template tags
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
# Required for inplace editing
'django.core.context_processors.request',
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
TEMPLATE_DIRS = (
TEMPLATE_PATH,
# os.path.join(BASE_DIR, 'templates', 'account'),
)
# Registration
REGISTRATION_OPEN = True
LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/sputnik/'
LOGOUT_URL = '/sputnik/'
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
)
# Inplace editting
INPLACEEDIT_EDIT_EMPTY_VALUE = '...'
INPLACEEDIT_AUTO_SAVE = True
INPLACEEDIT_EVENT = 'dblclick'
INPLACEEDIT_DISABLE_CLICK = True # For inplace edit text into a link tag
# INPLACEEDIT_EDIT_MESSAGE_TRANSLATION = 'Write a translation' # transmeta option
INPLACEEDIT_SUCCESS_TEXT = 'Successfully saved'
INPLACEEDIT_UNSAVED_TEXT = 'You have unsaved changes'
INPLACE_ENABLE_CLASS = 'enable'
# DEFAULT_INPLACE_EDIT_OPTIONS = {} # dictionary of the optionals parameters that the templatetag can receive to change its behavior (see the Advanced usage section)
# DEFAULT_INPLACE_EDIT_OPTIONS_ONE_BY_ONE = True # modify the behavior of the DEFAULT_INPLACE_EDIT_OPTIONS usage, if True then it use the default values not specified in your template, if False it uses these options only when the dictionnary is empty (when you do put any options in your template)
# ADAPTOR_INPLACEEDIT_EDIT = 'sputnik.perms.MyAdaptorEditInline' # Explain in Permission Adaptor API
# ADAPTOR_INPLACEEDIT = {'myadaptor': 'sputnik.fields.MyAdaptor'} # Explain in Adaptor API
# INPLACE_GET_FIELD_URL = None # to change the url where django-inplaceedit use to get a field
# INPLACE_SAVE_URL = None # to change the url where django-inplaceedit use to save a field
# Sites
SITE_ID = 1
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,
},
}
}
try:
from local_settings import *
except ImportError:
pass
編集:
Django、AWS、Apacheに関しては、私は相対的なn00bでもあります