I'm writing a web based code editor for Django projects. From within the editor I want to start the Django runserver command without it interfering with the server for the editor itself. Below is the code I use. The server (port 9999) is started but when I make a change to the code for the project whose server I just started both servers stop. The error is "That port is already in use"
def runserver(request, project_slug):
project = Project.objects.get(slug=project_slug)
import os
os.system('cd %s; pwd; env; DJANGO_SETTINGS_MODULE=%s.settings; rm nohup.out; nohup python manage.py runserver 0.0.0.0:9999 &' % (project.get_current_directory(), project.slug))
return HttpResponseRedirect(request.META['HTTP_REFERER'])