Hello all, very new to Django and am trying out the tutorial here and I can’t seem to get it to serve static content. I’ve performed the following configurations in my settings.py:
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_PATH = os.path.join(BASE_DIR,'static/')
STATIC_URL = '/static/'
STATICFILES_DIRS=(
STATIC_PATH,
)
my file is located at:
/home/django/django_project/static/images
when I use the full URL:
http://128.199.165.138/static/images/
I end up with the 404 Not Found nginx/1.4.6 (Ubuntu) error. Did I missed out on anything?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
turns out there’s one more step I missed. I had to go to nginx’s configuration file at
/etc/nginx/sites-available/django
to change the line from the previous one to reflect my folder arrangement.
location /static {
# alias /home/django/django_project/django_project/static;
alias /home/django/django_project/static;
}
restarted nginx and all is well!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.