How to check the version of a installed application in Django in running time?
django
Solution
A module / app will typically expose its version via a module level `__version__` attribute. For example:
import gunicorn
print gunicorn.__version__ # Prints version
import haystack
print haystack.__version__
Some caveats are in order:
- It is not guaranteed; check
- The "format" in which the app will expose its version will differ. For example, the first print above printed `'0.15.0'` on my test system; the second one printed `(2, 0, 0, 'beta')` on the same system.
Problem
I basically need to know the version of an specific application that it is installed and added to ``` INSTALLED_APPS = ( ... 'the_application', ... ) ``` I know that I can use pip freeze. I know the version of the application in my current virtual environment. The problem is I want to support two versions of the_application. Something like settings.INSTALLED_APP['the_application'].get_version() would be what I am looking for...