← Back to Django Course | Chapter 1: Django Fundamentals & Setup | Lesson 7 of 9

Django Project की संरचना

एक Django project folders और files में organized होता है जिनमें हर एक का एक clear job होता है, एक घर के rooms की तरह जो हर एक कुछ अलग के लिए उपयोग होते हैं।

Outer Project Folder

startproject से बना top-level folder manage.py और inner settings package रखता है; पूरे project की हर चीज़ इस एक folder के नीचे रहती है।

उदाहरण: The Outer Project Folder

ls right after startproject shows the outer folder contains just manage.py and one inner folder — everything for the whole project lives under this one directory.

bash
django-admin startproject mysite
ls mysite/

⚠️ Run this in your own terminal or Node.js environment.

Inner Settings Package

Outer folder के अंदर वही project नाम वाला एक और folder है, जिसमें settings.py, urls.py, wsgi.py, और asgi.py — असली configuration package होते हैं।

उदाहरण: The Inner Settings Package

The inner folder shares the project's name and holds settings.py, urls.py, wsgi.py, asgi.py, and __init__.py — the actual configuration package.

bash
ls mysite/mysite/

⚠️ Run this in your own terminal or Node.js environment.

settings.py क्या Control करता है

settings.py central configuration file है जहां आप installed apps, database connections, static file paths, और दूसरे project-wide options set करते हैं।

उदाहरण: What settings.py Controls

grep-ing settings.py for these names shows exactly where each key project-wide option — installed apps, database connection, middleware stack, template config — is declared.

bash
grep -n "INSTALLED_APPS\|DATABASES\|MIDDLEWARE\|TEMPLATES" mysite/mysite/settings.py

⚠️ Run this in your own terminal or Node.js environment.

urls.py की Role

Project-level urls.py पहली जगह है जहां Django एक incoming URL match करने के लिए देखता है, और यह typically include() उपयोग करके हर app के अपने urls.py को delegate करता है।

उदाहरण: The Role of urls.py

The project-level urls.py is the first stop for every request; here it hands off anything under /blog/ to the blog app's own urls.py via include().

markup
# mysite/urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('blog/', include('blog.urls')),
]
{# 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. #}
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. Outer project folder को inner settings package के साथ confuse करना जिसका नाम similar है।
  2. migrations folders के अंदर files को हाथ से edit करना बजाय Django को उन्हें generate करने देने के।
  3. App-specific code को सीधे project settings folder में रखना बजाय उसके अपने app के अंदर।
चैप्टर सारांश
  • एक नए project में एक outer folder और वही नाम वाला एक inner settings package होता है।
  • settings.py project-wide configuration रखता है जैसे installed apps और database settings।
  • urls.py project level पर URLs को views से map करता है।
  • manage.py project run करने के लिए command-line entry point है।

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.