python - Get the path to Django itself -


I have some code that runs on each (almost) every administrator request but 'do not have access to the request' object.

I need to find the path to the Django installation. I could:

  imported degengo django_path = django.__ file__  

but it seems useless even in the midst of a request.

Is the module importing at the beginning of the trash? I'm pretty sure that I remember a clear move.

In the Python process, import ed (if you have it, if your code Is, for example, in the visual function), it will not be "anything" * by importing it again - then go crazy, use import django; Django .__ File __ .

Now, if the system is not imported by the current Python process (for example, you have os.system ("Myscript.py") and myscript.py are required to determine the path of the demo), then importing agents will be a bit useless. But increasing each new process on each request too is quite useless ... so if efficiency is important, then maybe import myscript anyway.

*: Actually it will set a value in a dictionary ... but it is "nothing".


Comments