部署在AWS上时未找到Django-inplaceedit静态文件

时间:2015-10-28 00:43:47

标签: django amazon-web-services amazon-ec2 apache2 django-inplaceedit

长时间听众,第一次打电话给我,如果我错过了任何信息,请告诉我。

我目前有一个运行Django应用程序的AWS EC2实例。我当前的任务是在我使用django-inplaceedit(v 1.4.1)的表上执行就地编辑。在开发环境中,我已将其启动并运行,但在部署到暂存/生产时,无法找到静态(.js和.css)文件。我正在运行Apache服务器,但不确定如何让Apache查看Django放置这些静态文件的位置。

由于要转移到其他东西的压力,我可耻地将这些文件复制到应用程序的静态文件夹并将其作为(希望临时修复)。

提前感谢您的帮助! :)

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

0 个答案:

没有答案