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.0.tar.gz (8.2 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.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_netcast-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 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.0.tar.gz
Algorithm Hash digest
SHA256 33e5e3f698aacc0d289202ca35c2580ef54e7cf56cc81cc0e5d788892633596f
MD5 c9b50ca4f1452f182b0075f71eb4e1f6
BLAKE2b-256 c848eab799b1c514a1adcfcf467b2c7f015e0f9e0a132f85c6d05df2bc221ad6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_netcast-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4615c2994dbff7ee73d76372013ac80ea04c56d2e1d71e2758582107873be53
MD5 bcb01a1f2bfebee00896f96c49c8ad58
BLAKE2b-256 b4d064bffabff489e3430922c5e2dda04c4253399e52b68ab3586509945075f2

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