timonweb / django-tailwind

Django + Tailwind CSS = 💚
https://django-tailwind.readthedocs.io
MIT License
1.48k stars 91 forks source link

Django Tailwind not working on DEBUG = False #195

Open wolfred24 opened 9 months ago

wolfred24 commented 9 months ago

Hi guys,

I'm having an annoyng issue, i had deployed my django app in to a server, then i changed from DEBUG = True to DEBUG = False in the settings.py file, And magically no styles load at my app. The issue is that my web app is now displaying pure html without any style. And this only happens when i set the DEBUG = False config.

I already tried:

Nothing is working to solve this issue, and the terminal log doesnt show any error.

python3 manage.py tailwind start

> theme@3.6.0 start
> npm run dev

> theme@3.6.0 dev
> cross-env NODE_ENV=development tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css -w

Rebuilding...

Done in 499ms.

python3 manage.py tailwind build

> theme@3.6.0 build
> npm run build:clean && npm run build:tailwind

> theme@3.6.0 build:clean
> rimraf ../static/css/dist

> theme@3.6.0 build:tailwind
> cross-env NODE_ENV=production tailwindcss --postcss -i ./src/styles.css -o ../static/css/dist/styles.css --minify

Rebuilding...

Done in 530ms.

This is how my webpage looks: image

NatanSlvdr commented 8 months ago

Django doesn't serve static files in production mode (DEBUG = False) so you need to serve them yourself.

To do it you need either a webserver like Nginx/Apache have them server the /static/ folder and proxy the remaining to django or use whitenoise to serve your static css file.