· NGSRV Team

How to share a Django dev server online

You finished a feature branch and someone off your machine needs to click through it. Deploying a staging build works, but it is slow. Running python manage.py runserver and tunneling it is faster.

Stick to the dev server for previews. Do not expose runserver to production traffic.

Steps

# 1. Start Django
python manage.py runserver

# 2. In another terminal, tunnel the port
ngsrv http 8000

Check settings.py if the dev server complains about the hostname.

If the dev server blocks the public host

Add the ngsrv hostname to ALLOWED_HOSTS in settings.py.

Reserve a URL that does not change

ngsrv http 8000 --subdomain django-preview

Hand that link to QA or a client. Same URL after you restart the tunnel.

Declarative config for teams

Check a ngsrv.yml into the repo so everyone runs the same tunnel names:

tunnels:
  - name: django
    port: 8000
    subdomain: django-preview

Then ngsrv run.