Django DDP assistance

故事扮演 提交于 2019-12-10 20:59:17

问题


I'm sorry for this question I am not yet an expert to both django and meteorjs. I am trying to use this django-ddp technology but I am a little stuck on "Start the Django DDP service" on the Example Usage instruction at https://github.com/commoncode/django-ddp

I created a virtualenv,
I created a project named tutorial,
I followed the example usage instructions from the start until,
Every time I tried to run this command (DJANGO_SETTINGS_MODULE=tutorial.settings dddp) in shell I always get a response of "ImportError: No module named tutorial.settings"

P.S.: I even tried to package the project dir but still no luck.


回答1:


It would seem the issue is that your project isn't on the PYTHONPATH.

I had this issue when I wanted to set DDDP to be called from a executable python file. So, I created a file called run_dddp.py and added this:

#!/usr/bin/env python
import os
import subprocess

if __name__ == "__main__":
    new_env = os.environ
    new_env['PYTHONPATH'] = '/path/to/your/project'
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings")
    subprocess.call(['dddp'], env=new_env)

That adds the location of your project to the path and passes it to dddp.

I suppose you could also just modify the dddp exectuable and add in sys.path.append(/path/to/your/project) there as well or just add it to the path before calling DDDP every time, too. But the file above was just easier for me.



来源:https://stackoverflow.com/questions/34280559/django-ddp-assistance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!