We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
First, I'm aware of issue #66 but the problem I'm experiencing doesn't get fixed by running collectstatic.
collectstatic
I'm doing all of these experiments on a minimal Django 2.1.3 project with a fresh app, running on Python 3.7 and using whitenoise 4.1.1:
Django==2.1.3 psycopg2==2.7.6.1 pytz==2018.7 selenium==3.141.0 urllib3==1.24.1 whitenoise==4.1.1
The starting settings are:
DEBUG=True STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static")
and at that point the tests look good. The test itself looks like this:
from django.contrib.auth.models import User from django.contrib.staticfiles.testing import StaticLiveServerTestCase from selenium import webdriver from selenium.webdriver.common.keys import Keys class TestImportCRMData(StaticLiveServerTestCase): @classmethod def setUpClass(cls): super().setUpClass() cls.webdriver = webdriver.Chrome() cls.webdriver.implicitly_wait(10) @classmethod def tearDownClass(cls): cls.webdriver.close() cls.webdriver.quit() super().tearDownClass() def setUp(self): self.admin = User.objects.create_superuser(username="username", password="password", email="example@example.com") def test_navigate_to_import_crm_data(self): self.webdriver.get(f"{self.live_server_url}/admin") self.webdriver.find_element_by_id("id_username").send_keys("username") self.webdriver.find_element_by_id("id_password").send_keys("password") self.webdriver.find_element_by_id("id_password").send_keys(Keys.RETURN) self.webdriver.find_element_by_link_text("Users").click()
which should run in any application with the stock Django admin. When I add the app:
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', # ... ]
and:
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
and I run the test, I get
Server Error (500)
on the browser and
UserWarning: No directory at: C:\Users\pupeno\Temporary\untitled\static\ warnings.warn(u'No directory at: {}'.format(root))
on the terminal. Even with DEBUG set to True. If I run collectstatic , then the test run, but all the static file URL return a 404.
DEBUG
True
I tried setting DEBUG to False and the behavior was exactly the same.
False
The text was updated successfully, but these errors were encountered:
If you just use LiveServerTestCase instead of StaticLiveServerTestCase it should all work.
LiveServerTestCase
StaticLiveServerTestCase
Sorry, something went wrong.
That works and makes sense. Would you like me to add this information to the docs?
Great, glad to hear it! Thanks for the offer, but I need to do some work on the docs anyway so I should just add a note on this myself.
No branches or pull requests
First, I'm aware of issue #66 but the problem I'm experiencing doesn't get fixed by running
collectstatic
.I'm doing all of these experiments on a minimal Django 2.1.3 project with a fresh app, running on Python 3.7 and using whitenoise 4.1.1:
The starting settings are:
and at that point the tests look good. The test itself looks like this:
which should run in any application with the stock Django admin. When I add the app:
and:
and I run the test, I get
on the browser and
on the terminal. Even with
DEBUG
set toTrue
. If I runcollectstatic
, then the test run, but all the static file URL return a 404.I tried setting
DEBUG
toFalse
and the behavior was exactly the same.The text was updated successfully, but these errors were encountered: