Skip to main content

A zero-config Django command to instantly share your local development server on your Wi-Fi network.

Project description

๐Ÿ“ก django-netcast

Instantly share your Django dev server with any device on your Wi-Fi โ€” zero configuration required.

No more editing ALLOWED_HOSTS. No more Googling "what's my IP". No more 0.0.0.0 confusion.
Just run one command and open the URL on your phone.

python manage.py share_local
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚     django-netcast ยท LAN server running             โ”‚
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
  โ”‚  Local:    http://127.0.0.1:8000/                    โ”‚
  โ”‚  Network:  http://182.178.1.42:8000/                 โ”‚
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
  โ”‚  โš   Anyone on your Wi-Fi can access this!            โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Features

Feature Details
Zero config No changes to settings.py needed
LAN IP auto-detection Uses the OS routing table โ€” works on macOS, Linux & Windows
ALLOWED_HOSTS injection Automatically adds the LAN IP at runtime
CSRF_TRUSTED_ORIGINS Adds the correct http:// origin so Django admin & POST forms work from mobile
Static files Inherits from staticfiles runserver โ€” your CSS/JS just works
Auto-reload Subclasses Django's runserver โ€” file watching & auto-restart included
Offline-safe Gracefully falls back to 127.0.0.1 when no network is found
No dependencies Only uses the Python standard library + Django itself

Installation

pip install django-netcast

Then add it to your INSTALLED_APPS:

# settings.py
INSTALLED_APPS = [
    # ...
    "netcast",
]

That's it. No middleware, no URLs, no database migrations.


Usage

Basic (default port 8000)

python manage.py share_local

Custom port

python manage.py share_local 9000

All standard runserver flags work

python manage.py share_local --noreload --nothreading

How It Works

  1. Resolves your LAN IP โ€” Opens a dummy UDP socket to 8.8.8.8 (no data is sent) and reads which local interface the OS would route through.
  2. Patches ALLOWED_HOSTS โ€” Adds 0.0.0.0, 127.0.0.1, localhost, and your LAN IP in-memory so Django doesn't reject the request.
  3. Patches CSRF_TRUSTED_ORIGINS โ€” Adds http://<LAN-IP>:<PORT> so POST requests (forms, admin login) work from other devices without CSRF errors.
  4. Binds to 0.0.0.0 โ€” Tells the server to listen on all network interfaces instead of just localhost.
  5. Prints a clean banner โ€” Shows clickable local and network URLs, plus a security reminder.

Note: All changes are in-memory only โ€” your settings.py file is never modified.


Security

This tool is designed exclusively for local development.

  • It binds your server to all network interfaces (0.0.0.0).
  • Anyone connected to the same Wi-Fi network can access your dev server.
  • Never use this in production. Use a proper WSGI/ASGI server behind a reverse proxy instead.

FAQ

Does this modify my settings.py?

No. All changes happen in-memory at runtime. Your files are completely untouched.

Does it work offline?

Yes. When no network is detected, it falls back to 127.0.0.1 and works like the normal runserver.

Can I use this with Docker?

It's designed for bare-metal local development. Inside Docker, network exposure is typically handled by port mapping (-p 8000:8000).

Does auto-reload still work?

Yes. share_local subclasses Django's own runserver, so file watching, auto-restart, and threading all behave exactly the same.

Does it serve static files?

Yes. It inherits from the staticfiles variant of runserver, so {% static %} tags work out of the box during development.


Compatibility

Supported
Python 3.9, 3.10, 3.11, 3.12, 3.13
Django 4.2, 5.0, 5.1+
OS macOS, Linux, Windows

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

# Clone the repo
git clone https://github.com/sagar9187/django-netcast.git
cd django-netcast

# Install in editable mode with test dependencies
pip install -e ".[dev]"

# Run tests
pytest

License

MIT โ€” see LICENSE for details.


Built with โค๏ธ for developers who test on their phones.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_netcast-0.1.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_netcast-0.1.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file django_netcast-0.1.1.tar.gz.

File metadata

  • Download URL: django_netcast-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for django_netcast-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5e70d5be9bb7e12ba0360452c887d2f7ed59f999489a416c0054663e14f42b92
MD5 0f5002d1d3bf9d2caf5f40f8afdb3c2e
BLAKE2b-256 f2fbc572d3f1b33f581c1717e3b7ed59f9001744003ade8b480c950124635301

See more details on using hashes here.

File details

Details for the file django_netcast-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_netcast-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for django_netcast-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2149b5568873638ec6d01f3197bce7390744fe33eff64d082075cdefc3c72352
MD5 62893f3237a8728f34be624c1de670cc
BLAKE2b-256 9a2a9a3eccf1bd90bda04fec3965bce43218129c9867276345a192ededb84acb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page