{"action":"created","issue":{"url":"https://api.github.com/repos/Miserlou/Zappa/issues/1657","repository_url":"https://api.github.com/repos/Miserlou/Zappa","labels_url":"https://api.github.com/repos/Miserlou/Zappa/issues/1657/labels{/name}","comments_url":"https://api.github.com/repos/Miserlou/Zappa/issues/1657/comments","events_url":"https://api.github.com/repos/Miserlou/Zappa/issues/1657/events","html_url":"https://github.com/Miserlou/Zappa/issues/1657","id":371069771,"node_id":"MDU6SXNzdWUzNzEwNjk3NzE=","number":1657,"title":"Media files does not show up in production","user":{"login":"Abishek05","id":32245288,"node_id":"MDQ6VXNlcjMyMjQ1Mjg4","avatar_url":"https://avatars1.githubusercontent.com/u/32245288?v=4","gravatar_id":"","url":"https://api.github.com/users/Abishek05","html_url":"https://github.com/Abishek05","followers_url":"https://api.github.com/users/Abishek05/followers","following_url":"https://api.github.com/users/Abishek05/following{/other_user}","gists_url":"https://api.github.com/users/Abishek05/gists{/gist_id}","starred_url":"https://api.github.com/users/Abishek05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Abishek05/subscriptions","organizations_url":"https://api.github.com/users/Abishek05/orgs","repos_url":"https://api.github.com/users/Abishek05/repos","events_url":"https://api.github.com/users/Abishek05/events{/privacy}","received_events_url":"https://api.github.com/users/Abishek05/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-17T13:17:34Z","updated_at":"2018-10-17T14:21:28Z","closed_at":null,"author_association":"NONE","body":"<!--- Provide a general summary of the issue in the Title above -->\r\n## Context\r\n<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->\r\n<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 2.7/3.6 -->\r\n- Hello, I'm using [django cms](https://github.com/divio/django-cms). Media files are not displayed after i deploy the application. when i try to upload an image using carousel slides, the request times out. Image uploads are not successful.\r\n\r\n- I'm facing this issue only in production environment. I've setup the static path and media path pointing to aws s3 bucket using [django storages ](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html).\r\n\r\n- Although static files are being loaded from s3.\r\n\r\n- Database used- AWS RDS mysql instance\r\n## Expected Behavior\r\n<!--- Tell us what should happen -->\r\nMedia files such as images should be loaded from s3.\r\n## Actual Behavior\r\n<!--- Tell us what happens instead -->\r\nMedia files are not being loaded in production. Upload images are unsuccessful.\r\n## Possible Fix\r\nI'm not sure, but something in zappa is not substituting the media files url properly after the project is zipped.\r\n\r\n## Steps to Reproduce\r\n<!--- Provide a link to a live example, or an unambiguous set of steps to -->\r\n<!--- reproduce this bug include code to reproduce, if relevant -->\r\n1. Install django cms, django storages.\r\n2. Modify settings.py and custom_storages.py accordingly.\r\n3. Deploy\r\n\r\n- settings.py\r\n~~~~\r\nimport os  # isort:skip\r\ngettext = lambda s: s\r\nDATA_DIR = os.path.dirname(os.path.dirname(__file__))\r\n\"\"\"\r\nDjango settings for mysite project.\r\n\r\nGenerated by 'django-admin startproject' using Django 1.11.15.\r\n\r\nFor more information on this file, see\r\nhttps://docs.djangoproject.com/en/1.11/topics/settings/\r\n\r\nFor the full list of settings and their values, see\r\nhttps://docs.djangoproject.com/en/1.11/ref/settings/\r\n\"\"\"\r\n\r\nimport os\r\n\r\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\r\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\r\n\r\n\r\n# Quick-start development settings - unsuitable for production\r\n# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/\r\n\r\n# SECURITY WARNING: keep the secret key used in production secret!\r\nSECRET_KEY = '2d-yyc@k&d%5&o2p8hje#duncrtmx8)2vig69$k_@5_bubigygfc'\r\n\r\n# SECURITY WARNING: don't run with debug turned on in production!\r\nDEBUG = False\r\n\r\nALLOWED_HOSTS = ['*']\r\n\r\n\r\n# Application definition\r\n\r\n\r\n\r\n\r\n\r\nROOT_URLCONF = 'mysite.urls'\r\n\r\n\r\n\r\n\r\n# Internationalization\r\n# https://docs.djangoproject.com/en/1.11/topics/i18n/\r\n\r\nLANGUAGE_CODE = 'en'\r\n\r\nTIME_ZONE = 'Asia/Calcutta'\r\n\r\nUSE_I18N = True\r\n\r\nUSE_L10N = True\r\n\r\nUSE_TZ = True\r\n\r\n\r\n# Static files (CSS, JavaScript, Images)\r\n# https://docs.djangoproject.com/en/1.11/howto/static-files/\r\n\r\n# STATIC_URL = '/static/'\r\n# MEDIA_URL = '/media/'\r\n# MEDIA_ROOT = os.path.join(DATA_DIR, 'media')\r\n# STATIC_ROOT = os.path.join(DATA_DIR, 'static')\r\n\r\nSTATICFILES_DIRS = (\r\n    os.path.join(BASE_DIR, 'mysite', 'static'),\r\n)\r\nSITE_ID = 1\r\n\r\n\r\nTEMPLATES = [\r\n    {\r\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\r\n        'DIRS': [os.path.join(BASE_DIR, 'mysite', 'templates'),],\r\n        'OPTIONS': {\r\n            'context_processors': [\r\n                'django.contrib.auth.context_processors.auth',\r\n                'django.contrib.messages.context_processors.messages',\r\n                'django.template.context_processors.i18n',\r\n                'django.template.context_processors.debug',\r\n                'django.template.context_processors.request',\r\n                'django.template.context_processors.media',\r\n                'django.template.context_processors.csrf',\r\n                'django.template.context_processors.tz',\r\n                'sekizai.context_processors.sekizai',\r\n                'django.template.context_processors.static',\r\n                'cms.context_processors.cms_settings'\r\n            ],\r\n            'loaders': [\r\n                'django.template.loaders.filesystem.Loader',\r\n                'django.template.loaders.app_directories.Loader',\r\n                'django.template.loaders.eggs.Loader'\r\n            ],\r\n        },\r\n    },\r\n]\r\n\r\n\r\nMIDDLEWARE = (\r\n    'cms.middleware.utils.ApphookReloadMiddleware',\r\n    'django.contrib.sessions.middleware.SessionMiddleware',\r\n    'django.middleware.csrf.CsrfViewMiddleware',\r\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\r\n    'django.contrib.messages.middleware.MessageMiddleware',\r\n    'django.middleware.locale.LocaleMiddleware',\r\n    'django.middleware.common.CommonMiddleware',\r\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\r\n    'cms.middleware.user.CurrentUserMiddleware',\r\n    'cms.middleware.page.CurrentPageMiddleware',\r\n    'cms.middleware.toolbar.ToolbarMiddleware',\r\n    'cms.middleware.language.LanguageCookieMiddleware'\r\n)\r\n\r\nINSTALLED_APPS = (\r\n    'djangocms_admin_style',\r\n    'django.contrib.auth',\r\n    'django.contrib.contenttypes',\r\n    'django.contrib.sessions',\r\n    'django.contrib.admin',\r\n    'django.contrib.sites',\r\n    'django.contrib.sitemaps',\r\n    'django.contrib.staticfiles',\r\n    'django.contrib.messages',\r\n    'cms',\r\n    'menus',\r\n    'sekizai',\r\n    'treebeard',\r\n    'djangocms_text_ckeditor',\r\n    'filer',\r\n    'easy_thumbnails',\r\n    'djangocms_column',\r\n    'djangocms_file',\r\n    'djangocms_link',\r\n    'djangocms_picture',\r\n    # 'djangocms_style',\r\n    'djangocms_snippet',\r\n    'djangocms_googlemap',\r\n    'djangocms_video',\r\n    'mysite',\r\n    'storages',\r\n    'zappa_django_utils',\r\n    'aldryn_style',\r\n    'djangocms_icon',\r\n    'djangocms_bootstrap4',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_alerts',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_badge',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_card',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_carousel',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_collapse',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_content',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_grid',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_jumbotron',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_link',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_listgroup',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_media',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_picture',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_tabs',\r\n    'djangocms_bootstrap4.contrib.bootstrap4_utilities',\r\n    'cmsplugin_filer_file',\r\n    'cmsplugin_filer_folder',\r\n    'cmsplugin_filer_link',\r\n    'cmsplugin_filer_image',\r\n    'cmsplugin_filer_teaser',\r\n    'cmsplugin_filer_video',\r\n)\r\n\r\nLANGUAGES = (\r\n    ## Customize this\r\n    ('en', gettext('en')),\r\n)\r\n\r\nCMS_LANGUAGES = {\r\n    ## Customize this\r\n    1: [\r\n        {\r\n            'code': 'en',\r\n            'name': gettext('en'),\r\n            'redirect_on_fallback': True,\r\n            'public': True,\r\n            'hide_untranslated': False,\r\n        },\r\n    ],\r\n    'default': {\r\n        'redirect_on_fallback': True,\r\n        'public': True,\r\n        'hide_untranslated': False,\r\n    },\r\n}\r\n\r\nCMS_TEMPLATES = (\r\n    ## Customize this\r\n    ('fullwidth.html', 'Fullwidth'),\r\n    # ('sidebar_left.html', 'Sidebar Left'),\r\n    # ('sidebar_right.html', 'Sidebar Right')\r\n    ('home.html', 'home'),\r\n)\r\n\r\nCMS_PERMISSION = True\r\n\r\nCMS_PLACEHOLDER_CONF = {}\r\n'''\r\nDATABASES = {\r\n    'default': {\r\n        'CONN_MAX_AGE': 0,\r\n        'ENGINE': 'django.db.backends.sqlite3',\r\n        'HOST': 'localhost',\r\n        'NAME': 'project.db',\r\n        'PASSWORD': '',\r\n        'PORT': '',\r\n        'USER': ''\r\n    }\r\n}\r\n'''\r\n'''\r\nDATABASES = {\r\n    'default': {\r\n        'ENGINE': 'django.db.backends.postgresql',\r\n        'NAME': 'rdzcivlp',\r\n        'USER': 'rdzcivlp',\r\n        'PASSWORD': 'DVv-uJ8d0FL7SO1sTCBaBXGgbuug0b',\r\n        'HOST': 'baasu.db.elephantsql.com',\r\n        'PORT': '5432'\r\n    }\r\n}\r\n'''\r\n'''\r\nDATABASES = {\r\n    'default': {\r\n        'ENGINE': 'django.db.backends.postgresql',\r\n        'NAME': 'cmscoldchip',\r\n        'USER': 'blackweb',\r\n        'PASSWORD': '$hnpiiy8gbb97ttgbi80',\r\n        'HOST': 'webinstance.cyrb6swhdrez.us-west-2.rds.amazonaws.com',\r\n        'PORT': '5432'\r\n    }\r\n}\r\n'''\r\nDATABASES = {\r\n    'default': {\r\n        'ENGINE': 'django.db.backends.mysql',\r\n        'NAME': 'cmscoldchip',\r\n        'USER': 'blackweb',\r\n        'PASSWORD': 'jn[mm[0i9hgbiiyif75ed7utfj',\r\n        'HOST': 'webinstance-mysql.cyrb6swhdrez.us-west-2.rds.amazonaws.com',\r\n        'PORT': '3306'\r\n    }\r\n}\r\n\r\nMIGRATION_MODULES = {\r\n    \r\n}\r\n\r\nTHUMBNAIL_PROCESSORS = (\r\n    'easy_thumbnails.processors.colorspace',\r\n    'easy_thumbnails.processors.autocrop',\r\n    'filer.thumbnail_processors.scale_and_crop_with_subject_location',\r\n    'easy_thumbnails.processors.filters'\r\n)\r\n\r\n# DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\r\n# STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'\r\n\r\nAWS_STORAGE_BUCKET_NAME = 'zappa-djangostaticcms'\r\nAWS_ACCESS_KEY_ID = 'AKIAJ35I3SP3SUJBHJGJH'\r\nAWS_SECRET_ACCESS_KEY = 'R1RM6GwYSB1tRFNXT0RgFv4IIhih80y9080'\r\nAWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME\r\n\r\n# STATICFILES_LOCATION = 'static'\r\n# STATICFILES_STORAGE = 'custom_storages.StaticStorage'\r\n\r\n# MEDIAFILES_LOCATION = 'media'\r\n# DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'\r\n\r\n# STATIC_URL = \"https://%s/\" % AWS_S3_CUSTOM_DOMAIN\r\n# MEDIA_URL = \"https://%s/\" % AWS_S3_CUSTOM_DOMAIN\r\n\r\nSTATICFILES_LOCATION = 'static'\r\nSTATICFILES_STORAGE = 'custom_storages.StaticStorage'\r\nSTATIC_URL = \"https://%s/%s/\" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION)\r\n\r\nMEDIAFILES_LOCATION = 'media'\r\nMEDIA_URL = \"https://%s/%s/\" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION)\r\nDEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'\r\n\r\nAWS_S3_REGION_NAME = 'us-west-2'\r\nMEDIA_ROOT = MEDIA_URL\r\n\r\nAWS_DEFAULT_ACL = None\r\nAWS_QUERYSTRING_AUTH = False\r\n\r\n~~~~\r\n\r\n- custom_storages.py\r\n~~~~\r\n# custom_storages.py\r\nfrom django.conf import settings\r\nfrom storages.backends.s3boto3 import S3Boto3Storage\r\n\r\n\r\nclass StaticStorage(S3Boto3Storage):\r\n    location = settings.STATICFILES_LOCATION\r\n\r\n\r\nclass MediaStorage(S3Boto3Storage):\r\n    location = settings.MEDIAFILES_LOCATION\r\n\r\n~~~~\r\n\r\n- urls.py\r\n~~~~\r\n# -*- coding: utf-8 -*-\r\nfrom __future__ import absolute_import, print_function, unicode_literals\r\n\r\nfrom cms.sitemaps import CMSSitemap\r\nfrom django.conf import settings\r\nfrom django.conf.urls import include, url\r\nfrom django.conf.urls.i18n import i18n_patterns\r\nfrom django.contrib import admin\r\nfrom django.contrib.sitemaps.views import sitemap\r\nfrom django.contrib.staticfiles.urls import staticfiles_urlpatterns\r\nfrom django.views.static import serve\r\n\r\nadmin.autodiscover()\r\n\r\nurlpatterns = [\r\n    url(r'^sitemap\\.xml$', sitemap,\r\n        {'sitemaps': {'cmspages': CMSSitemap}}),\r\n]\r\n\r\nurlpatterns += i18n_patterns(\r\n    url(r'^admin/', include(admin.site.urls)),  # NOQA\r\n    url(r'^', include('cms.urls')),\r\n)\r\n\r\n# This is only needed when using runserver.\r\nif settings.DEBUG:\r\n    urlpatterns = [\r\n        url(r'^media/(?P<path>.*)$', serve,\r\n            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),\r\n        ] + staticfiles_urlpatterns() + urlpatterns\r\n\r\n~~~~\r\n\r\n## Your Environment\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n* Zappa version used: 0.47.0\r\n* Operating System and Python version: windows 7, Python version: 3.6.3\r\n* Django version: 1.11.15\r\n* django CMS version: 3.5.2\r\n* The output of `pip freeze`:\r\naldryn-style==1.1.4\r\nargcomplete==1.9.3\r\nbase58==1.0.0\r\nboto==2.49.0\r\nboto3==1.9.24\r\nbotocore==1.12.24\r\ncertifi==2018.10.15\r\ncfn-flip==1.0.3\r\nchardet==3.0.4\r\nClick==7.0\r\ncmsplugin-filer==1.1.3\r\ndj-database-url==0.5.0\r\nDjango==1.11.15\r\ndjango-appconf==1.0.2\r\ndjango-classy-tags==0.8.0\r\ndjango-cms==3.5.2\r\ndjango-filer==1.3.2\r\ndjango-formtools==2.1\r\ndjango-mptt==0.8.7\r\ndjango-polymorphic==2.0.3\r\ndjango-sekizai==0.10.0\r\ndjango-storages==1.7.1\r\ndjango-treebeard==4.3\r\ndjangocms-admin-style==1.2.8\r\ndjangocms-attributes-field==0.3.0\r\ndjangocms-bootstrap4==1.1.1\r\ndjangocms-column==1.8.0\r\ndjangocms-file==2.0.2\r\ndjangocms-googlemap==1.1.1\r\ndjangocms-icon==1.0.0\r\ndjangocms-installer==1.0.1\r\ndjangocms-link==2.1.2\r\ndjangocms-picture==2.0.6\r\ndjangocms-snippet==2.0.0\r\ndjangocms-text-ckeditor==3.6.0\r\ndjangocms-video==2.0.4\r\ndocutils==0.14\r\ndurationpy==0.5\r\neasy-thumbnails==2.5\r\nfuture==0.16.0\r\nhjson==3.0.1\r\nhtml5lib==0.9999999\r\nidna==2.7\r\njmespath==0.9.3\r\nkappa==0.6.0\r\nlambda-packages==0.20.0\r\nmysqlclient==1.3.12\r\nolefile==0.46\r\nPillow==5.2.0\r\nplacebo==0.8.2\r\npsycopg2==2.7.5\r\npython-dateutil==2.6.1\r\npython-slugify==1.2.4\r\npytz==2018.5\r\nPyYAML==3.13\r\nrequests==2.19.1\r\ns3transfer==0.1.13\r\nsix==1.11.0\r\ntoml==0.10.0\r\ntqdm==4.19.1\r\ntroposphere==2.3.3\r\ntzlocal==1.5.1\r\nUnidecode==0.4.21\r\nurllib3==1.23\r\nWerkzeug==0.14.1\r\nwsgi-request-logger==0.4.6\r\nzappa==0.47.0\r\nzappa-django-utils==0.4.0\r\n\r\n\r\n* Your `zappa_settings.py`: \r\n{\r\n    \"production\": {\r\n        \"aws_region\": \"us-west-2\",\r\n        \"django_settings\": \"mysite.settings\",\r\n        \"profile_name\": \"serverless-admin\",\r\n        \"project_name\": \"cmscoldchip\",\r\n        \"runtime\": \"python3.6\",\r\n        \"s3_bucket\": \"zappa-cmscoldchip-code\"\r\n    }\r\n}"},"comment":{"url":"https://api.github.com/repos/Miserlou/Zappa/issues/comments/430648235","html_url":"https://github.com/Miserlou/Zappa/issues/1657#issuecomment-430648235","issue_url":"https://api.github.com/repos/Miserlou/Zappa/issues/1657","id":430648235,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDY0ODIzNQ==","user":{"login":"superappy","id":3349172,"node_id":"MDQ6VXNlcjMzNDkxNzI=","avatar_url":"https://avatars2.githubusercontent.com/u/3349172?v=4","gravatar_id":"","url":"https://api.github.com/users/superappy","html_url":"https://github.com/superappy","followers_url":"https://api.github.com/users/superappy/followers","following_url":"https://api.github.com/users/superappy/following{/other_user}","gists_url":"https://api.github.com/users/superappy/gists{/gist_id}","starred_url":"https://api.github.com/users/superappy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superappy/subscriptions","organizations_url":"https://api.github.com/users/superappy/orgs","repos_url":"https://api.github.com/users/superappy/repos","events_url":"https://api.github.com/users/superappy/events{/privacy}","received_events_url":"https://api.github.com/users/superappy/received_events","type":"User","site_admin":false},"created_at":"2018-10-17T14:21:28Z","updated_at":"2018-10-17T14:21:28Z","author_association":"NONE","body":"Dude you have posted a lot of critical configs related to your environment. Replace them ASAP before anyone misuses them. Be careful in future !"}}
{"actor":{"display_login":"superappy"}}