
![]() |
@wtf | |
Django High-Level Web Framework |
||
1
Replies
20
Views
1 Bookmarks
|
![]() |
@wtf | 8 August 25 |
Django is a powerful, full-stack Python web framework that encourages clean, rapid development and pragmatic design perfect for building secure and scalable web apps. Why Use Django? Batteries-included (ORM, admin panel, auth, etc.) Fast, secure & scalable Follows the DRY principle Built-in protection against common attacks (CSRF, SQL injection) Strong community & documentation Basic Project Setup bash pip install django django-admin startproject myproject cd myproject python manage.py runserver Creating an App bash python manage.py startapp blog Define a Model (ORM) python from django.db import models class Post(models.Model): title = models.CharField(max_length=100) content = models.TextField() Create and Apply Migrations bash python manage.py makemigrations python manage.py migrate Register Models in Admin Panel python from django.contrib import admin from .models import Post admin.site.register(Post) Rendering Views & Templates python from django.shortcuts import render def home(request): return render(request, 'home.html') URL Routing python from django.urls import path from . import views urlpatterns = [ path('', views.home, name='home'), ] Real-World Use Cases Full-featured websites & CMS E-commerce platforms Social networks APIs with Django REST Framework (DRF) Summary Ideal For: Enterprise-level apps, admin-heavy platforms Strength: Security, scalability, rapidl development Bonus: Comes with an auto-generated admin interface |
||


