Django Deployment की Checklist
In this page:
एक Production Server Install करना
manage.py runserver एक lightweight development server है जो real traffic को safely या efficiently handle करने के लिए नहीं बना। Gunicorn एक WSGI server है जो वही Django application एक production-appropriate तरीके से run करता है।
उदाहरण: Installing a Production Server
manage.py runserver is a lightweight development server not built to handle real traffic safely or efficiently. Gunicorn is a WSGI server that runs the same Django application in a production-appropriate way.
pip install gunicorn
gunicorn myproject.wsgi:application
⚠️ Run this in your own terminal or Node.js environment.
Deploy पर Migrations Apply करना
नए model changes शामिल करने वाले हर deploy को इसकी migrations production database पर apply करनी होती हैं, exactly development के दौरान जैसे, सिर्फ local database के बजाय live database की ओर pointed।
उदाहरण: Applying Migrations on Deploy
Every deploy that includes new model changes needs its migrations applied to the production database, exactly like during development, just pointed at the live database instead of the local one.
python manage.py migrate
⚠️ Run this in your own terminal or Node.js environment.
एक Minimal Deployment Checklist
हर deploy से पहले, checks की एक छोटी list सबसे common mistakes पकड़ती है: DEBUG off है, ALLOWED_HOSTS सही है, static files collect हो गई हैं, और migrations apply हो गई हैं।
उदाहरण: A Minimal Deployment Checklist
Before each deploy, a short list of checks catches the most common mistakes: DEBUG is off, ALLOWED_HOSTS is correct, static files are collected, and migrations are applied.
# Deployment checklist (run in order)
# 1. python manage.py check --deploy
# 2. python manage.py collectstatic --noinput
# 3. python manage.py migrate
# 4. gunicorn myproject.wsgi:application
⚠️ Run this in your own terminal or Node.js environment.
- Production में एक real WSGI server के बजाय development server (
runserver) run करना। - नए model changes deploy करने के बाद production database पर migrations skip करना।
- Production
SECRET_KEYको एक environment variable के बजाय version control में store करना।
- Production Django को
manage.py runserverनहीं, Gunicorn जैसे एक real WSGI application server की ज़रूरत है। - Migrations production database पर apply होनी चाहिए, सिर्फ local वाले पर नहीं।
- Environment-specific settings (secret key, debug flag, allowed hosts) codebase के बजाय environment से आनी चाहिए।
- एक छोटी, repeatable checklist हर release पर वही mistakes होने से रोकती है।
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: