8👍
✅
You need to run the script as follows:
/manage.py runscript scripts.syllabus.first --script-args=excel.xlsx
Here scripts and syllabus are two directories containing __init__.py
.
2👍
I dont have any experience with django. But the problem can be solved by adding syllabus
to module lookup path. To do that add the following code in the __init__.py
file under scripts
directory.
import sys
import os
curr_path = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, curr_path + '/syllabus')
Or another way is to tell python that syllabus
is a module itself. In that case you just need to rename first.py
to __init__.py
. You will then have to invoke it as
./manage.py runscript syllabus --script-args=excel.xlsx
- [Django]-Show management commands in admin site
- [Django]-What's the easiest way to Import a CSV file into a Django Model?
- [Django]-Python – Single thread executor already being used, would deadlock
- [Django]-How to extend UserCreationForm with fields from UserProfile
- [Django]-Implement zeromq publisher in django with celery (Broker redis)
Source:stackexchange.com