I have uploded my django proejct on cloudfare through gunicorn but i seems like my css is not loading in it

Static files (CSS, JavaScript, Images)


Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'

This is where you put your uncollected static files


This is where collected static files will be placed

STATIC_ROOT = BASE_DIR / 'staticfiles'

Default primary key field type


i want to make the css visible in my software

1. Update settings.py:

Modify your settings.py to include configure static file settings:

import os

# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

    os.path.join(BASE_DIR, 'static'),

2. Collect Static Files:

Run the collectstatic management command to collect all static files into the STATIC_ROOT directory:

python manage.py collectstatic

This command collects all static files from your applications (including third-party apps) into one location (STATIC_ROOT), which you've defined in your settings.

By following these steps, you should be able to resolve the issue of CSS files not loading in your Django project deployed on Cloudflare via Gunicorn.

Back to Top