Open AntonGyaltsen opened 2 months ago
extra actions for seting up static for test:
extra actions for seting up static for test:
- pip install django-debug-toolbar -in setings.py Add debug_toolbar.middleware.DebugToolbarMiddleware to MIDDLEWARE.
Dubug toolbar is not necessary. I forgot to exclude it from instruction. It is mostly for testing sql-queries (which based on queries through Django ORM in view functions) for optimisation.
The issue you're encountering with Django's admin panel static files not rendering on Heroku while having
DEBUG=True
often relates to how static files are handled in production environments like Heroku. Here’s a step-by-step approach to resolve the problem:When
DEBUG=False
, Django will not serve static files by default, so you need to ensure proper static file handling.2. Set
ALLOWED_HOSTS
:Make sure you have set the
ALLOWED_HOSTS
in yoursettings.py
file, which should include your Heroku app's domain and other hosts you intend to use:3. Use
whitenoise
for Static Files:Heroku doesn’t serve static files automatically, so you need to configure a middleware to handle this.
whitenoise
is a popular package used to serve static files in production.Install
whitenoise
:Update your
settings.py
to integratewhitenoise
by adding it to theMIDDLEWARE
section and configuring static files settings:In main urls.py — Иначе не будет работать при Debug = True