]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Allow importing lcp_django from other python scripts master
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 26 Feb 2016 14:49:41 +0000 (15:49 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 26 Feb 2016 14:55:26 +0000 (15:55 +0100)
It is now sufficient to include "import lcp_django" in other python
scripts and then use lcp_django.models...

scripts/lcp_django/__init__.py [new file with mode: 0644]

diff --git a/scripts/lcp_django/__init__.py b/scripts/lcp_django/__init__.py
new file mode 100644 (file)
index 0000000..c1bd8b6
--- /dev/null
@@ -0,0 +1,12 @@
+import os
+import sys
+
+this_dir = os.path.abspath(os.path.dirname(__file__))
+if not this_dir in sys.path:
+    sys.path.insert(0, this_dir)
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "database.settings")
+
+import django
+django.setup()
+import database.models as models