Impossible to export static in django production

django serving media files in production
django serve static files in production
django static files
django static files not found in production
django static files not working
django nginx static files
django static files 404
django static 'css

I'm trying to put in production a website using nginx and gunicorn but after a lot of attempt, my css and js are not visable.

The project root is /root/ouverture

My static files root is /root/ouverture/coloc/static

here it's what i have written in my settings.py

STATIC_ROOT  = "/static/" 
STATIC_URL = '/static/'

here is my /etc/nginx/sites-available/coloc

server {
    listen 80; server_name 51.91.111.135;
    root /root/ouverture/;
    location /static {
            root /root/ouverture/coloc/;
    }
    location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;
            proxy_pass http://127.0.0.1:8000;
    }

}

Can you help me please, I don't see where is my error. Thank you

Why have you set STATIC_ROOT = "/static/"? You want the static files to go into /root/ouverture/coloc/static, so that's what you should set STATIC_ROOT to. Then make sure you run collectstatic.

Managing static files (e.g. images, JavaScript, CSS), In your templates, use the static template tag to build the URL for the given relative name in a different application, Django would be unable to distinguish between them. For some common deployment strategies, see Deploying static files. For more information, see Django and Static Assets (Heroku docs). Whitenoise. There are many ways to serve static files in production (we saw the relevant Django settings in the previous sections). Heroku recommends using the WhiteNoise project for serving of static assets directly from Gunicorn in production.

There are something wrong with your configuration which you might want to take a look at that.

  1. Your static files root. My static files root is /root/ouverture/coloc/static with this, your STATIC_ROOT supposed to be STATIC_ROOT='/root/ouverture/coloc/static' or maybe something like this STATIC_ROOT=os.path.join(BASE_DIR, 'static') and BASE_DIR is your project DIR (BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

  2. You're trying to serve your application and also static files too so you might not need root, alias also works.

    location /static/ {
         alias /root/ouverture/coloc/static/;
    }

Just remember to run ./manage.py collectstatic on your project so that your static files will be copied into STATIC_ROOT folder, check that your static files are there first, and then do it step by step until you can see any static files on /static/ path.

Deploying static files | Django documentation, Of course, as with all deployment tasks, the devil's in the details. Every production setup will be a bit  Impossible to export static in django production Posted on October 5, 2019 at 1:50 PM by Stack Overflow RSS I'm trying to put in production a website using nginx and gunicorn but after a lot of attempt, my css and js are not visable.

I have change my static_root to "/root/ouverture/coloc/static" and made the changes in the config files nginx. i've done the collectstatic too. but still the same problem, i only have the html but without css and js withtout any error..

Top 10 Django Mistakes, Whether you're an expert or a new developer taking your first stab at Django, these is going to become difficult to maintain, especially when your dev, production, moment export the application into another Python package and use it again. In production, you serve your static using a standalone web server like Nginx. There's more info in the django docs. Set up a static files mapping. Finally, set up a static files mapping to get our web servers to serve out your static files for you. Go to the Web tab on the PythonAnywhere dashboard; Go to the Static Files section; Enter the same URL as STATIC_URL in the url section (typically, /static/)

Django Tutorial Part 11: Deploying Django to production, That's the end of this tutorial on setting up Django apps in production, Choose an environment for hosting any static files. export DJANGO_DEBUG=False Rather than hard-coding this information into Django, Heroku  django.contrib.staticfiles collects static files from each of your applications (and any other places you specify) into a single location that can easily be served in production. See also For an introduction to the static files app and some usage examples, see Managing static files (e.g. images, JavaScript, CSS) .

Django Static Files, Django Static Files for Dummies. When you deploy your app to the production, you want to configure your web server (e.g. NGINX) to look for  Configured all basic Django settings and features like cacheable Django templates in production, hashed static files, integrated debug toolbar, logging, etc. It’s a ready-to-use Django Skeleton for your next project from scratch and will, hopefully, save you a lot of time by bootstrapping your project.

S3 Static & Media Files for Django | Post, Using Amazon Web Services (AWS) S3 For storing static and media files Unable to - Create Own Policy in IAM option for create own policy is not there. It's more important that you "export" from production and "import" to  Note. In order to send email, Django requires a few settings telling it how to connect to your mail server. At the very least, you’ll need to specify EMAIL_HOST and possibly EMAIL_HOST_USER and EMAIL_HOST_PASSWORD, though other settings may be also required depending on your mail server’s configuration.