45👍
✅
Instead of using LiveServerTestCase from django.test
you can use
StaticLiveServerTestCase from django.contrib.staticfiles.testing
.
Notice not just the different class-name, but also the different module-name:
from django.test import LiveServerTestCase
# ^-- vs --v
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
9👍
Ok I found the solution. First I had to add in setting
STATIC_ROOT = 'my static dir'
then:
./manage.py collectstatic
👤tstr
- [Django]-How do I get user IP address in Django?
- [Django]-Going from twitter date to Python datetime date
- [Django]-You are trying to add a non-nullable field 'id' to contact_info without a default
3👍
I had a similar issue and none of the answers above helped me.
For anyone using Whitenoise as a static file server, it turns out you may have to change the value of the STATICFILES_STORAGE
setting in your app, from:
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
To:
STATICFILES_STORAGE = "whitenoise.storage.CompressedStaticFilesStorage"
That fixed my problem. See this page for more information.
- [Django]-Django rest framework, use different serializers in the same ModelViewSet
- [Django]-Editing Django _form.as_p
- [Django]-Distributed task queues (Ex. Celery) vs crontab scripts
Source:stackexchange.com