Ticket #1796: prolog.py

File prolog.py, 614 bytes (added by virtel@…, 17 years ago)

The others didn't work for me. This is another workaround for standalone scripts, with a different approach. Works in VERSION (0,95.1, None)

Line 
1### prelude to stand-alone-script
2### fixing http://code.djangoproject.com/ticket/1796
3### configure project_directory below
4
5project_directory = "/home/virtel/projekte/moblog/blogposter"
6
7
8### next few lines copied from django/core/management.py
9
10import os,sys
11project_name = os.path.basename(project_directory)
12sys.path.append(os.path.join(project_directory, '..'))
13project_module = __import__(project_name, '', '', [''])
14sys.path.pop()
15os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name
16
17
18if not project_directory in sys.path :
19 sys.path.append(project_directory)
20
21### start your script here
22
Back to Top