I have a Django project that I added to AWS. in the development server the site works perfectly fine however I am not able to get my static files to my aws site
Below is my project Tree and static files are in the project
Below is my settings.py
Below is my nginx server
Below is my supervisor.conf
[program:Khal]
command = /home/samir/KhalEventsVenv/bin/uwsgi --http :9000 --wsgi-file /home/samir/khal-events/src/Khal/Khal/wsgi.py
directory = /home/samir/khal-events/src/Khal/
user = root
autostart = true
autorestart = true
stdout_logfile = /var/log/Khal.log
stderr_logfile = /var/log/Khal_err.log
Changed the nginx to
server {
listen 80 default_server;
location /static/admin {
alias /home/samir/KhalEventsVenv/lib/python3.6/site-packages/django/contrib/admin/static/admin;
}
location /static/ {
alias /home/samir/khal-events/src/Khal/staticfiles;
}
Still the page is not getting the static in see image below
I have checked the paths. they are good. However for some reason when I run the site from AWS it is not getting the staticfiles also when I got to the admin page. The static files for admin are not in there too. HOw can I get my static files in AWS
As suggested by @CoolestNerdIII
It appears as though in your django settings file, you define the static file directory to be
/home/samir/khal-events/src/Khal/staticfiles
(based on your screenshot of yourcollectstatic
command and yoursettings.py
file).In your nginx config file, however, you are looking for your static directory inside of
home/samir/khal-events/src/Khal/static
. You need to change this to the correct path, and you should be good to go. (meaning use/home/samir/khal-events/src/Khal/staticfiles
)Update #1:
You should remove the
/static/admin
from your nginx. Also, you can try duplicating your/static
group with/static/
. Make sure you restart your nginx service after you make the changes.Finally, if neither if these appear to display the page correctly, check the console log in your web browser, as well as the nginx logs, as they typically point to where information is being loaded improperly.
Update #2: