Development Server चलाना
In this page:
python manage.py runserver
python manage.py runserver port_number
Development Server Start करना
Project folder से "python manage.py runserver" run करना एक local web server start करता है, और Django वह address print करता है जहां आप अपनी site एक browser में देख सकते हैं।
उदाहरण: Starting the Development Server
Starts Django's built-in development server on the default port.
python manage.py runserver
⚠️ Run this in your own terminal or Node.js environment.
एक अलग Port चुनना
runserver के बाद एक port number जोड़ना, जैसे "python manage.py runserver 8080", server को default 8000 के बजाय उस port पर start करता है।
उदाहरण: Choosing a Different Port
Starts the development server on port 8080 instead of the default.
python manage.py runserver 8080
⚠️ Run this in your own terminal or Node.js environment.
Code Changes पर Auto-Reload
Development server आपकी Python files देखता है और जब भी आप कोई change save करते हैं अपने आप restart हो जाता है, इसलिए आपको शायद ही कभी इसे manually stop और start करना पड़ता है।
उदाहरण: Auto-Reload on Code Changes
StatReloader watches every .py file in the project; saving one prints this line and restarts the server for you automatically — no manual stop/start needed.
python manage.py runserver
Watching for file changes with StatReloader
⚠️ Run this in your own terminal or Node.js environment.
Production में क्यों उपयोग न करें
Development server single-threaded है और असली traffic के नीचे security या performance के लिए optimized नहीं है, इसलिए production sites इसके बजाय Nginx के पीछे Gunicorn जैसे servers उपयोग करती हैं।
उदाहरण: Why Not to Use It in Production
This is the real command that replaces runserver in production — Gunicorn (usually paired with Nginx) is a production-grade WSGI server; runserver is single-threaded and refuses that role on purpose.
pip install gunicorn
gunicorn mysite.wsgi:application
⚠️ Run this in your own terminal or Node.js environment.
- Server run करने से पहले migrations apply करना भूल जाना, जो पहले load पर database errors का कारण बनता है।
- Project folder के बाहर server run करना जहां manage.py मौजूद नहीं।
- Production में proper production web server के बजाय development server उपयोग करना।
- Command "python manage.py runserver" Django का built-in development server start करता है।
- By default यह http://127.0.0.1:8000/ पर run होता है।
- जब आप Python files में changes save करते हैं server auto-reload होता है।
- यह सिर्फ local development के लिए है, कभी production traffic के लिए नहीं।
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: