← Back to Django Course | Chapter 2: Apps, URLs & Views | Lesson 3 of 10

INSTALLED_APPS में Apps Register करना

INSTALLED_APPS एक guest list जैसा है — Django एक toy box (app) को party में सिर्फ तभी join करने देता है जब उसका नाम उस list पर लिखा हो।
Syntax
markup
INSTALLED_APPS = [
    'django.contrib.admin',
    # ... built-in apps
    'app_name',
]

INSTALLED_APPS Setting

settings.py में INSTALLED_APPS नाम की एक Python list होती है। यह Django की built-in apps (admin, auth, sessions) से शुरू होती है और यहीं आप हर app जोड़ते हैं जो आप बनाते या install करते हैं।

उदाहरण: The INSTALLED_APPS Setting

settings.py contains a Python list called INSTALLED_APPS. It starts with Django's built-in apps (admin, auth, sessions) and is where you add every app you create or install.

markup
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'blog',
]
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}

Short Name vs AppConfig Path

आप एक app को इसके short package name (blog) से या सीधे इसके AppConfig class ('blog.apps.BlogConfig') को point करके register कर सकते हैं। दोनों identically काम करते हैं; explicit path उपयोगी है जब एक app custom AppConfig behavior define करे।

Note: AppConfig path को prefer करें जब app default_auto_field override करे या एक ready() hook जोड़े।

उदाहरण: Short Name vs AppConfig Path

You can register an app by its short package name (blog) or by pointing directly at its AppConfig class ('blog.apps.BlogConfig'). Both work identically; the explicit path is useful when an app defines custom AppConfig behavior.

markup
INSTALLED_APPS = [
    # ...
    'blog.apps.BlogConfig',
]
{# Django-only code -- models.py/views.py/urls.py/settings.py snippets, or template markup using Django template tags/variables -- can't run standalone via Judge0 or the browser preview, since it needs a real Django project. Only this course's pure-Python examples (example_lang == 'python', no Django imports) are actually runnable, so those still get the button below. #}

Registration क्यों मायने रखता है

सिर्फ INSTALLED_APPS में listed apps के ही models makemigrations द्वारा discover होते हैं, admin.py load होता है, और templates/static folders Django के template और staticfiles finders द्वारा search होते हैं।

उदाहरण: Why Registration Matters

Only apps listed in INSTALLED_APPS get their models discovered by makemigrations, their admin.py loaded, and their templates/static folders searched by Django's template and staticfiles finders.

bash
python manage.py makemigrations
# 'No changes detected' if the app isn't in INSTALLED_APPS yet

⚠️ 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. startapp से एक app बनाना लेकिन इसे कभी INSTALLED_APPS में न जोड़ना, इसलिए इसके models कभी migrate नहीं होते।
  2. गलत dotted path जोड़ना (जैसे 'blog.apps' बजाय 'blog.apps.BlogConfig' या सिर्फ blog)।
  3. एक custom app को Django की built-in apps से पहले इस तरह रखना जो template या static file overriding order को तोड़ दे।
चैप्टर सारांश
  • settings.py में INSTALLED_APPS हर app की list है जो Django load करेगा।
  • Short form (blog) और AppConfig dotted path ('blog.apps.BlogConfig') दोनों entries के रूप में काम करते हैं।
  • एक app के models, admin, और template tags Django के लिए invisible हैं जब तक यह इस list में दिखाई न दे।

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.