I cloned a GitHub repo. Everything is working fine. But I need to populate sample data for all the endpoints. There about 20 files with sample data for each endpoint. Then there is a file(dataload.py) in the root folder that should call all those 20 files and populate the database.
I ran python dataload.py but I got the error
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
This is the content of dataload.py
from subprocess import call
print ('**** starting ***')
SETTINGS_FILE= 'promedic.settings_prod'
# SETTINGS_FILE= 'promedic.settings'
call(['python', 'manage.py', 'makemigrations', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'migrate', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/allergies.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/blood_group.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/disabilities.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/drug-forms.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/drug-brands.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/dispense-types.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/genotypes.json', '--settings=%s'% SETTINGS_FILE])
call(['python', 'manage.py', 'loaddata', 'core/fixtures/states.json', '--settings=%s'% SETTINGS_FILE])
I have change dataload.py to
from django.core.management import call_command
#from subprocess import call
print ('**** starting ***')
SETTINGS_FILE= 'promedic.settings_prod'
# SETTINGS_FILE= 'promedic.settings'
'''
call_command('makemigrations', )
call_command('migrate')
'''
call_command('loaddata', 'core/fixtures/allergies.json', settings='SETTINGS_FILE')
call_command('loaddata', 'core/fixtures/blood_group.json', settings='SETTINGS_FILE')
Now getting this error
in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.