question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django Static files serving

See original GitHub issue

Hello am new to nginx proxy manger and soo far i have understood the workflow however in the location section am having a bit of trouble… am running a django app with gunicorn which only handles python code hence my static files(javaScript & CSS) are not being served… i want to include them in the location area but every time I do it the host goes offline… if I used an nginx config file traditionally this is what it would look like

server {
    listen 80;
    server_name YOUR_IP_ADDRESS;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/djangoadmin/pyapps/btre_project;
    }
    
    location /media/ {
        root /home/djangoadmin/pyapps/btre_project;    
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

I want the proxy params , media and static to be included in location but I can’t find a way… kindly assist

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
Maxino22commented, Oct 2, 2022

you welcome… Glad i could help 🔥

0reactions
snake-softcommented, Dec 17, 2022

It can cause problems when adding an advanced configuration and enable “cache assets”. I got a 404 trying to load asset files (Django static and media). It works after disabling “cache assets”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to manage static files (e.g. images, JavaScript, CSS)
Websites generally need to serve additional files such as images, JavaScript, or CSS. In Django, we refer to these files as “static files”....
Read more >
How do you serve static files when using the django runserver ...
Create a folder called media inside static and keep all your media files inside that. Run python manage.py collectstatic to collect all your...
Read more >
Serving Static Files - Matt Layman
An alternative approach to using Django to serve static files is to use another program as a reverse proxy. This setup is more...
Read more >
Working with Static and Media Files in Django | TestDriven.io
STATICFILES_DIRS: By default, static files are stored at the app-level at <APP_NAME>/static/ . The collectstatic command will look for static ...
Read more >
Serving static files with Django - API Bakery
If you're using cloud storage such as Amazon S3, you probably use the excellent django-storages. It makes serving static files directly from the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found