Access Denied - CloudFront + Django Compressor - python

Just started using django compressor along with my AWS/Cloudfront setup on Heroku.
Having an issue on my local machine where the compressed CSS and JS files are not loading for the page and when i view the source (CSS Example)
It is showing as “Access Denied”
https://d3dycr1vdfv0cd.cloudfront.net/static/CACHE/css/50c1fe094e5d.css
I thought this might be a permissions issue on my S3 bucket and clicked on “Make Public” on my CSS folder in S3. But still no luck.
any ideas?

Related

Images not loading when deploying Django app to Heroku

I deployed my app to heroku: https://doggos-only.herokuapp.com/
The images on the Dog Images link work locally, but they do not work on the deployed version. The only useful error I'm getting is: cj_eOAaboi.jpg:1 Failed to load resource: the server responded with a status of 404 (Not Found)
My best guess is that it has something to do with the file path, but I'm not sure. I've tried looking around the web for a solution but have been unable to find one. Looking for any help, here is the repo: https://github.com/jpchato/doggos_only_project
I'm deploying from the deploy_branch in my repo.
That's because media files (Those files uploaded by the user) in heroku are not persistent, that means that after a certain time all the media will be erased.
I strongly suggest you to use a media CDN like cloudinary or amazon s3.
I wrote a post on how to setup a media CDN with cloudinary for free and you can access it right here
Django Tutorial: Set up Media files in Deployment for FREE

Django static files not being served by amazon s3 even though all the instructions have been strictly followed

This is my first time ever on this platform, so please don't mind me if I am breaching any rules. I just finished building my first django project and I am using an amazon s3 bucket to serve media and static files. I have deployed the app onto heroku but static and media files are not being loaded. When I inspect the page, I see that it is throwing a 403 error. All the policies of my bucket have been set as prescribed in the documentation. below is a picture of my relevant setting.py
settings .py

Aws Lambda + Django + django-storages + collectstatic inconsistent behaviour

I am running aws lambda.
It is deployed with zappa.
Lambda runs a django project.
Django uses django-storages lib to use S3 for storage and serving static files.
I run collectstatic successfully.
I see my admin page with fully loaded js and css.
Next day I come back and see plain html admin page without js and css loaded. I continue navigating through admin page and after some time css and js magically loads. I continue doing some work and css/js again dissapears and admin page becomes plain html again.
Anyone experiencing something similar? Any ideas of why is this happening?
EDIT:
Lambda is invoked through API Gateway

Deploying Django - Most static files are appearing except images

Most of my static files on my newly deployed Django website are working (CSS), but not the images. All the images are broken links for some reason and I cannot figure out why. I am serving my static files via Amazon AWS S3.
I believe all my settings are configured correctly as the collectstatic command works (and the css styling sheets are up on the web). What could be the problem?
It's probably impossible to give an accurate assessment with the limited info on your setup. If your css files are working what folder are they sitting in on your server?
Why not have images folder in the same directory and set that directory to your MEDIA_URL in your settings.py file?
In your browser check your images full path and compare that to your CSS files, where are they pointing, do you have a directory on your server where they are supposed to be? are you receiving an access denied if you try to directly put in that image url into your browser?

js and css files are not read in a DJANGO project

I am reformulating a previous question because I think it was formulated as a Python problem but it is a Django one.
I am installing a project from github called publicmarkup:
The main page displays on the browser but no media (neither js files, nor css files) are read loaded. There is a module called mediasync that seems to be necessary to display correctly the css and the js files of the templates.
I think this a configuration problem. Here's the link settings.py file, Here it could be find the root path of the media folder.
And here's the doc for the mediasync modulet explains how to configure static_url
But I didn't understand anything since I am a newbie to djnago
In Django you have to set up your own workstation serve static files, in both dev and live modes.
You can read about it here.
This explains how to serve static files in your dev environment.
In live mode you serve your static files directly via your end web server, usually either Apache or Nginx.

Categories