Live Updates
Initializing JARVIS Data Stream... Synchronizing Feeds...
Important

Anti-Fraud Alert: This portal does not charge any service fees from candidates. All services provided here are 100% Free of Cost. Please stay cautious of unauthorized individuals asking for money.

DJANGO BASIC

 

🌐 Django – Basic Notes


1️⃣ Django Kya Hai?

Definition:
Django → Python ka high-level web framework jo fast aur secure websites banane ke liye use hota hai.

Important Points:

  • Backend web development ke liye
  • Built-in features → Authentication, Admin, Database
  • MTV architecture (Model-Template-View)

2️⃣ Django Features

  • Rapid Development → Fast website build
  • Secure → SQL injection, XSS se protection
  • Scalable → Large websites handle kar sakta hai
  • ORM → Database queries Python code se

3️⃣ Django Setup

pip install django
django-admin startproject mysite
cd mysite
python manage.py runserver
  • Run: localhost:8000 browser me

4️⃣ Project Structure

mysite/
manage.py
mysite/
settings.py
urls.py
wsgi.py

Explanation:

  • manage.py → Commands run karne ke liye
  • settings.py → Configuration
  • urls.py → URLs route define

5️⃣ App Creation

python manage.py startapp blog
  • Project me multiple apps → modular

6️⃣ URLs & Views

URL Mapping

# urls.py
from django.urls import path
from . import views

urlpatterns = [
path('', views.home),
]

View Function

# views.py
from django.http import HttpResponse

def home(request):
return HttpResponse("Hello Django")

7️⃣ Templates

  • HTML files for frontend
  • Django template tags: {{ variable }}

Example:

<h1>Hello {{ name }}</h1>

8️⃣ Models (Database)

from django.db import models

class Student(models.Model):
name = models.CharField(max_length=50)
age = models.IntegerField()
  • models.py → Database table define