In my Django application I am using the staticfiles app in conjunction with Whitenoise.
My web server is accessible via two domains and I would like to serve different static files for each.
My idea was that www.my_domain.com/static/ would serve up, say, the files in os.path.join(BASE_DIR, "staticfiles/my_domain/")
, and vice-versa for www.my_other_domain.com/static/.
What is the best way of achieving this? I have thought of three solutions:
- Subclass the places in which
STATIC_ROOT
is accessed, so that it takes the domain into account - Use nginx to route www.my_domain.com/static/my_domain/ to www.my_domain.com/static/
- Use Django middleware to achieve the same result as 2. (like this stack overflow question)
Thank you!