[Fixed]-Django CDN with Nginx and uWSGI

1👍

It might be just a spelling mistake. In your settings.py you have an extra n in the directory name.

STATIC_ROOT = 'nonAppBoundStaticDirectory'

In your nginx config, you have a different spelling.

location /static {
    alias /home/ofey/djangoForum/noAppBoundStaticDirectory; 

Make sure that the path point to the exact same directory. It’s can be a good idea to use absolute paths in both cases.

0👍

  1. Working in development server

If you are working in development server- remove STATIC_ROOT from settings.py. Your settings.py should now look like this:

    STATIC_URL = '/static/'

    STATICFILES_DIRS = [
        os.path.join(BASE_DIR, 'static'),
    ]
  1. Production

If you are working in production- remove STATICFILES_DIRS from settings.py. Your settings.py should now look like this:

    STATIC_URL = '/static/'

    STATIC_ROOT = 'nonAppBoundStaticDirectory'

And don’t forget to run:

    python manage.py collectstatic

Leave a comment