当前位置: 动力学知识库 > 问答 > 编程问答 >

python - django running mutliple sites in development

问题描述:

Am currently developing a website that consists of mutliple sites in the same project therefore I have several settings.py files each with different SITE_ID. As am developing, everytime I have to go through the 8 settings files and start up the runserver one by one to do full testing and navigate between the sites.

Is there a way for me to run them all at once? I tried to do a command line utility for that but the management.call_command interface does not allow to fire off a process in the background.

Any ideas how can i build something?

网友答案:

You can't background it directly through the python interface, but you can simply run one process per site. For example, in bash, something like

for site in settings_{a,b,c,d}; do
    python manage.py runserver --settings $site &
done

If you want to run it in python, try the subprocess module, or you could run management.call_command through a multiprocessing.Pool.

You'll want to run these on different ports as well, as Variant mentioned.

网友答案:

You can run the multiple sites each in a different port. to do this you can start the sites up like this:

/manage.py runserver portnum

where you can change the port number (i.e. 8002, 8003, etc...) for each site

分享给朋友:
您可能感兴趣的文章:
随机阅读: