Automatically run the Django dev server on a particular hostname
Project description
Run Server on Hostname
My problem: I have multiple Django projects, but when I use the dev server (./manage.py runserver), they clobber each others' cookies since they run at 127.0.0.1 by default.
The manual solution: I set my hostfile (/etc/hosts) up so that each project has its own pseudo-hostname. Usually this is "projectname.localhost". But that means I have to remember which name I gave to each project and remember to pass it every time I ./manage runserver.
This package lets me define a desired dev server hostname in my Django settings, then runserver will respect it by default. If for any reason, I want to override that setting on a one-off basis, that still works.
Installation
- Install the
django-runserveronhostnamepackage using whatever package manager you prefer (I useuv). - Add
runserveronhostnametoINSTALLED_APPSin your Django settings. - Add a setting
RUNSERVER_ON = 'myname.whatever:8000'(you must include a port number). This could also be used to bind to a particular IP address (RUNSERVER_ON = '0.0.0.0:8000') if you prefer.
Important note: this package doesn't do anything about making sure you can actually bind to the requested name or IP address. You will need to manually add an entry to your hostfile, DNS, etc.
Usage
When you run the dev server (./manage.py runserver, django-admin runserver, etc.), if you have RUNSERVER_ON defined, it'll use that. This works with any runserver implementation:
- naive implementation in Django
staticfilesimplementation in Djangodaphne's runserver override
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_runserveronhostname-0.1.0.tar.gz.
File metadata
- Download URL: django_runserveronhostname-0.1.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
832c461ce90d21f26151b1ebb2e36243b25491dfdd76f9f1e43d21572e02d196
|
|
| MD5 |
e1be4afe0152f0de8f20e858558c4428
|
|
| BLAKE2b-256 |
88fdfb7debcc88ca03c2af16000692fe94a8b1d0159213f29108bb5c1e48f79c
|
File details
Details for the file django_runserveronhostname-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_runserveronhostname-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f69fe94362cd8ddd8de8326ecd109275ba4c119d1b49a672fba20e4fcfe25d48
|
|
| MD5 |
8c6080efcb33beb96812de1d43b101a1
|
|
| BLAKE2b-256 |
97dc1945844b3f7ed6fbb60aac2fcb19ab6587e09ca36556a96210925c3da801
|