Bird
0
0

Given this settings.py snippet:

medium📝 state output Q4 of 15
Django - Deployment and Production
Given this settings.py snippet:
MIDDLEWARE = [
  'django.middleware.security.SecurityMiddleware',
  'whitenoise.middleware.WhiteNoiseMiddleware',
  'django.middleware.common.CommonMiddleware',
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

What happens when you run collectstatic?
AStatic files are collected, compressed, and hashed for caching
BStatic files are collected but not compressed
CStatic files are not collected due to middleware order
DAn error occurs because WhiteNoiseMiddleware is missing
Step-by-Step Solution
Solution:
  1. Step 1: Analyze STATICFILES_STORAGE setting

    Using CompressedManifestStaticFilesStorage compresses and hashes static files during collectstatic.
  2. Step 2: Check middleware order

    Middleware order is correct; WhiteNoiseMiddleware is present and after SecurityMiddleware.
  3. Final Answer:

    Static files are collected, compressed, and hashed for caching -> Option A
  4. Quick Check:

    Collectstatic with WhiteNoise compression = Static files are collected, compressed, and hashed for caching [OK]
Quick Trick: CompressedManifestStaticFilesStorage compresses on collectstatic [OK]
Common Mistakes:
MISTAKES
  • Assuming compression happens without correct STATICFILES_STORAGE
  • Thinking middleware order blocks collectstatic

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes