-
Notifications
You must be signed in to change notification settings - Fork 20
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
Staticfiles fix #715
Staticfiles fix #715
Conversation
This reverts commit 5375b1a.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dope 😎 Thanks for the fix! Had some minor questions but otherwise LGTM
"staticfiles": { | ||
"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change required? Or is it basically the "new way" to do things? (in which case, seems reasonable to switch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with this syntax vs the other and it seems necessary. According to the docs, this is needed for Django 4.2+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. FWIW, I think Django is still 4.1 in the poetry.lock file.
@@ -172,7 +177,7 @@ | |||
# Configure Django App for Heroku. | |||
import django_heroku | |||
|
|||
django_heroku.settings(locals(), test_runner=False) | |||
django_heroku.settings(locals(), test_runner=False, staticfiles=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a comment above this line pointing out that staticfiles=False
is to avoid clobbering previous settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this change come from?
cardboard/settings.py
Outdated
STATIC_URL = "/static/" | ||
STATICFILES_DIRS = [ | ||
os.path.join(BASE_DIR, "cardboard/static"), | ||
os.path.join(BASE_DIR, "hunts/static"), | ||
] | ||
STATICFILES_STORAGE = "whitenoise.django.CompressedManifestStaticFilesStorage" | ||
STORAGE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a typo, this setting is named STORAGES
https://docs.djangoproject.com/en/5.0/ref/settings/#storages
But it was also added in Django 4.2. In the pyproject.toml
we only have 4.1 specified and the package version in the poetry.lock
is also 4.1, so you should use the 4.1 settings (we should also upgrade Django to the latest version but probably in a separate PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops, you're right. I'll delete my staticfiles
directory and test from scratch again with this fixed.
@@ -172,7 +177,7 @@ | |||
# Configure Django App for Heroku. | |||
import django_heroku | |||
|
|||
django_heroku.settings(locals(), test_runner=False) | |||
django_heroku.settings(locals(), test_runner=False, staticfiles=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this change come from?
I think our settings are working ok and With that said we should probably just rip out that module wholesale and inline everything. That's what the creator recommends; looks like it's been deprecated for a couple years: heroku/django-heroku#56 |
Now that we have the webpack fix in #716, we can prob close this PR and followup with a separate |
It looks like there were 2 main issues with static files:
django_heroku.settings()
. Settingstaticfiles=False
means we're using our own settings.STATIC_ROOT
and the backend storage config was also incorrect. See https://whitenoise.readthedocs.io/en/latest/django.html for details.I also updated docker-entrypoint.sh to use the
--no-input
flag when runningcollectstatic
.