Q. What are the key principles to follow when organizing and configuring Django settings for a project, according to the “Django Settings Best Practices” reading?
Referenced from djangostars
Q. How does the White Noise library contribute to the efficient serving of static files in a Django application, and what are the steps to integrate it into a project?
add whitenoise to your MIDDLEWARE inside settings.py
MIDDLEWARE = [
# ...
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
# ...
]
Configure caching by adding…
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
under STATIC_URL = ‘/static/’ inside your settings.py.
Q. What is the purpose of Cross-Origin Resource Sharing (CORS) in web applications, and how can it be implemented and configured in a Django project to control access to resources?
specify CORS Settings inside settings.py
CORS_ALLOWED_ORIGINS = [
# List of allowed origins (domains) for cross-origin requests
# e.g., 'https://example.com'
]
CORS_ALLOW_METHODS = [
'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'
# List of allowed HTTP methods for cross-origin requests
]