Which of the following is the correct way to configure static files in Django production settings?
easy📝 Syntax Q3 of 15
Django - Deployment and Production
Which of the following is the correct way to configure static files in Django production settings?
ASTATIC_URL = '/static/' and STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
BSTATIC_URL = '/media/' and MEDIA_ROOT = os.path.join(BASE_DIR, 'static')
CSTATIC_ROOT = '/static/' and STATIC_URL = os.path.join(BASE_DIR, 'staticfiles')
DMEDIA_URL = '/static/' and STATIC_ROOT = os.path.join(BASE_DIR, 'mediafiles')
Step-by-Step Solution
Solution:
Step 1: Identify correct static file settings
STATIC_URL defines the URL path for static files; STATIC_ROOT defines the folder where static files are collected.
Step 2: Match correct values
STATIC_URL = '/static/' and STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') correctly sets STATIC_URL to '/static/' and STATIC_ROOT to a folder named 'staticfiles' inside the base directory.
Final Answer:
STATIC_URL = '/static/' and STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') -> Option A
Quick Check:
Static files URL and root [OK]
Quick Trick:STATIC_URL is URL path; STATIC_ROOT is folder path [OK]
Common Mistakes:
MISTAKES
Mixing MEDIA and STATIC settings
Swapping URL and folder variables
Master "Deployment and Production" in Django
9 interactive learning modes - each teaches the same concept differently