By default the server starts at http://127.0.0.1:8000/.
Starting the server
python manage.py runserver
By default the server starts at http://127.0.0.1:8000/.
Startup options
python manage.py runserver 8080 # different port
python manage.py runserver 0.0.0.0:8000 # accessible from the network
python manage.py runserver --noreload # disable auto-reload
Auto-reload
The server automatically restarts when Python files change. Exceptions:
- New files are not always picked up — a manual restart is required
- Template changes are picked up without a restart
What it does NOT do
- Not suitable for production — single-threaded, no optimizations
- Does not serve static files efficiently (but does serve them when
DEBUG=True) - Does not support HTTPS
DEBUG and static files
# settings.py
DEBUG = True # shows error pages, serves static files via runserver
With DEBUG=False static files are not served through runserver — whitenoise or nginx is required.
Console logs
[27/Jan/2024 10:30:00] "GET /tasks/ HTTP/1.1" 200 1234
[27/Jan/2024 10:30:01] "POST /tasks/new/ HTTP/1.1" 302 0
For production
pip install gunicorn
gunicorn mysite.wsgi --workers 4 --bind 0.0.0.0:8000
💬 Comments (0)
No comments yet
Be the first to share your opinion about this article!