Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django Tailwind not working on DEBUG = False #195

Open
wolfred24 opened this issue Feb 13, 2024 · 1 comment
Open

Django Tailwind not working on DEBUG = False #195

wolfred24 opened this issue Feb 13, 2024 · 1 comment

Comments

@wolfred24
Copy link

wolfred24 commented Feb 13, 2024

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:

  • Running an older version of my project.
  • Tried with multiple execution ports and urls.
  • I tried also locally and the same happens.

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

python3 manage.py tailwind start

> [email protected] start
> npm run dev


> [email protected] 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

> [email protected] build
> npm run build:clean && npm run build:tailwind


> [email protected] build:clean
> rimraf ../static/css/dist


> [email protected] 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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants