[Answered ]-Instantiate object "at module level" in Django

2đź‘Ť

âś…

I just mean the bottom level of that module, at the same indentation as the “from mpd…” and “class MPDProxy…” lines.

So, at the bottom of the file, without indenting at all, put proxy = MPDProxy() – and now you can reference that instance from anywhere by importing it with from lib.MPDProxy import proxy.

Leave a comment