Django Project की संरचना
In this page:
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.
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.
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.
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().
# 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. #}
- Outer project folder को inner settings package के साथ confuse करना जिसका नाम similar है।
- migrations folders के अंदर files को हाथ से edit करना बजाय Django को उन्हें generate करने देने के।
- 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 है।
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: