#๐Ÿ”’ Django CSS not working in Development Environment

4 messages ยท Page 1 of 1 (latest)

terse dragon
#

Hey all, I have a Django project and whatever I do, I can't seem to get the css to load in my sub apps.

My project is organized like so:

/{app}/src/{app}/apps/services/app1
/{app}/src/{app}/apps/services/app2

The css for app1 and app2 does not load. My settings.py has

DEBUG = True

STATIC_URL = "/static/"
MEDIA_URL = "/media/"

STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_ROOT = os.path.join(BASE_DIR, "media")

STATICFILE_DIRS = [BASE_DIR / "static"]

I've tried adding

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

to the urls.py, which didn't work.

And, python manage.py collectstatic doesn't seem to work either. I see the static files appear in the static dir in the base directory of the app, but it doesn't change anything.

Any help would be appreciated, thank you!

gloomy steepleBOT
#

@terse dragon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

gloomy steepleBOT
#

@terse dragon

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.