Search code examples
djangopython-3.xamazon-web-serviceswysiwygdjango-wysiwyg

How do I modify my Django settings for AWS Static files to accoomade for django summernote


I am using django-summernote as a wysiwyg editor. The editor works fine in my development stage. Where my Django setting is using the below code

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

However the moment I switch to production where my static files are saved on AWS. I do not see the summernote wysiwyg editor. Infact the the entire text-field disappears. Also My static files are working perfectly with everything else. My style.css file on my aws is the exactly the same as my dev stage below are are my AWS settings

AWS_DEFAULT_ACL = None
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]
DEFAULT_FILE_STORAGE = 'aws_storage_classes.MediaStorage'
AWS_STORAGE_BUCKET_NAME = 'cool-media-8axodgh6d'
STATICFILES_STORAGE = 'aws_storage_classes.StaticStorage'
AWS_S3_OBJECT_PARAMETERS = {
    'CacheControl': 'max-age=86400',
}

AWS_S3_DOMAIN = "%s.s3.amazonaws.com" % AWS_STORAGE_BUCKET_NAME

STATIC_URL = 'https://%s/static/' % AWS_S3_DOMAIN
MEDIA_URL = 'https://%s/media/' % AWS_S3_DOMAIN

ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

How can I fix this. Please let me know if you need more info. I would be more than happy to provide


Solution

  • I think you need to check your network section of the browser, to check if the required css and js are loading properly. There are documentations on how you can access network property on Firefox and Chrome.

    If you are using tools like django-storage, then running python manage.py collectstatic is usually suffice to push those static files in S3(or manually copy pasting files will work but not recommended).