I recently stumbled on this question on StackOverflow that explains how we can use the sites framework in tandem with DatabaseRouter to use different databases for each site.
Is there any way we can replicate the same for Storages?
Hello, this is Gulshan Negi.
Well, I did some Google searching for this, and I found that it is possible to use different storage backends for each site using Django’s Sites framework and Storage backends. This can be achieved by defining a custom storage backend that supports multiple databases, defining a custom storage class that instantiates the custom storage backend based on the current site’s ID, creating a middleware that sets the current site’s ID in thread-local storage, and registering the custom storage class in Django’s settings.py file. This approach provides a flexible way to use different storage backends for each site, similar to how the DatabaseRouter allows for different databases for each site.
I hope it is clear now.