Forums

import django module from not-django's script

when trying to run script, that use django's models, script says that error importing module from django's settings;

for example, it says: ImportError: No module named rssDj.rssDjApp; or "pymorphy"

but they are, and pymorphy installed, and works with django

there's script:

1 import os
2 import sys
3
4 sys.path.append('/home/kerniexvid/rssDj')
5 sys.path.append('/home/kerniexvid/rssDjApp')
6
7 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
8
9 import logging
10
11 from django.conf import settings
12
13 from datetime import datetime, timedelta
14 from rssReader.DatabaseTransactions import DatabaseTransactions
15 import datetime
16
17 if __name__ == '__main__':
18
19 fromDate = datetime.datetime.now()
20 toDate = datetime.datetime.now()
21 ey = DatabaseTransactions().loadTable_PrimaryData(fromDate, toDate)
22 print ey

Is rssReader your Django app? Is this the complete script or just part of it? And finally are rssDj and rssDjApp both separate Django projects? If they are then things could get really confused. Only the settings.py file inside rssDj would be being used. That could be part of the problem.

Other than that it looks okay :-) You're definitely getting close anyway.