Django: Objects that live throughout server lifetime

I have some data in csv format that I need to load into the application once and then reuse it throughout the lifetime of the application, which is across multiple requests. How can I do that?

An obvious method for me is to have a module that will load the data and then expose it. However, I don't like modules doing a lot of work, because then imports lead to unexpected side effects. I would like to do that one-time work in a predictable, deterministic fashion, not because someone imported a module.

Does Django provide some hooks for globals? Some kind of Application/Service class where I could do that work and then access the data in the requests?

Вернуться на верх