← Back to Django Course | Chapter 15: Security, Caching & Deployment | Lesson 7 of 9

Django Deployment की Checklist

एक deployment checklist एक pilot की pre-flight checklist जैसी है -- एक छोटी list जो आप हर बार run करते हैं ताकि एक छोटी mistake एक बड़ी problem न बन जाए एक बार आप हवा में हों।

एक 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.

bash
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।

Note: हर deploy के हिस्से के रूप में migrate run करें, भले ही लगे कि इसमें सिर्फ templates बदले।

उदाहरण: 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.

bash
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.

bash
# 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.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. Production में एक real WSGI server के बजाय development server (runserver) run करना।
  2. नए model changes deploy करने के बाद production database पर migrations skip करना।
  3. 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 होने से रोकती है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.