Anandi Sheladiya
Contact
  • About Anandi
  • SKILLS & EXPERIENCE
    • Frontend
      • ReactJS
      • Next.js – The React Framework for Production
      • ChartJS / D3.JS / Fabric JS
      • Three.JS: The JavaScript Library for 3D Graphics
      • HTML/CSS/JS/Tailwind CSS/Bootstrap
      • Material UI – The Ultimate React UI Framework
      • ShadCN/UI – The Modern UI Library for React
    • Backend
      • NodeJS & ExpressJS
      • Web3.JS
      • Python & Django
      • GoLang
      • TypeScript
    • Database
      • PostgreSQL
      • MongoDB - NOSQL Database
      • MySQL
    • API
      • REST API
      • GraphQL API
      • RPC (Remote Procedure Call)
      • WebSocket
    • Solidity
    • Layer 1 Blockchain
      • Ethereum
      • Solana
      • Bitcoin
      • Hyperledger
      • Binance
      • Avalanche
      • Cardano
      • Polkadot
      • Near Protocol
      • Algorand
      • TON (Telegram Open Network)
    • Optimistic Rollups (L2 on Ethereum)
      • Arbitrum
      • Base
      • Mantle
    • ZK-Rollups (L2 on Ethereum)
      • zkSync Era
      • Polygon zkEVM
    • Wallet Integration
      • Reown Appkit
      • Rainbow Walletkit
      • Web3 Modal
      • WalletConnect
      • Wagmi
      • Metamask & Safewallet SDKs
    • Web3 SDKs & API Providers
      • Alchemy
      • Moralis
      • QuickNode
      • BitQuery API & Stream
      • ThirdWeb
      • Infura
      • Li.Fi
      • 1Inch API
      • Uniswap API
      • OpenZeppelin
    • Web3 Middleware/ UX Infrastructure Platform
      • Biconomy
      • Pimlico
      • Alchemy AA
      • Safe (formerly Gnosis Safe)
      • ZeroDev
    • On Chain Trading Platform & Telegram Bot
      • Bullx
      • Wave Bot
      • GMGN
      • Shuriken
      • Magnum Trade
      • Trojan
  • PROTOCOLS
    • ERCs & EIPs
      • ERC-20: The Standard for Fungible Tokens
      • ERC-721: The Standard for Non-Fungible Tokens (NFTs)
      • ERC 4337
      • ERC 6551: Token Bound Accounts (TBA)
      • ERC 7702
      • EIP 4844 (Proto-Danksharding)
      • Ethereum Pectra
  • ARTICLES
    • Medium
Powered by GitBook
On this page
  • Introduction
  • Why Choose Python for Web Development?
  • Django – The Full-Featured Web Framework
  • 1️⃣ Installing Django
  • 5️⃣ Django Models – Database Handling
  • 7️⃣ Django Templates – Rendering HTML

Was this helpful?

  1. SKILLS & EXPERIENCE
  2. Backend

Python & Django

Introduction

Python is one of the most popular and versatile programming languages, widely used for web development, automation, data science, AI, and more. In web development, Django and Flask are two of the most widely used frameworks that simplify backend development.

Django is a full-stack web framework that follows the "batteries-included" philosophy, providing built-in tools for authentication, database management, and security.

Flask is a lightweight, minimalistic web framework that provides flexibility, allowing developers to build scalable web applications with custom features.

Why Choose Python for Web Development?

  • Easy to Learn – Simple and readable syntax.

  • Huge Ecosystem – Libraries for web, AI, ML, data science, etc.

  • Fast Development – Django and Flask reduce development time.

  • Scalability – Used by companies like Instagram, Pinterest, and Reddit.

  • Security – Django provides built-in security features.

Django – The Full-Featured Web Framework

1️⃣ Installing Django

Install Django using pip:

pip install django

Check if Django is installed:

django-admin --version

2️⃣ Creating a Django Project

django-admin startproject myproject
cd myproject
python manage.py runserver

Visit http://127.0.0.1:8000/ in your browser to see your Django project running!

3️⃣ Django Project Structure

myproject/
│── myproject/   # Main project settings
│── app/         # Application folder (models, views, templates)
│── manage.py    # Command-line utility
│── db.sqlite3   # Database

4️⃣ Creating a Django App

python manage.py startapp myapp

Register the app in settings.py:

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "myapp",  # Register your app
]

5️⃣ Django Models – Database Handling

Django uses ORM (Object-Relational Mapping) for database management.

Define a Model in models.py

from django.db import models

class Product(models.Model):
    name = models.CharField(max_length=255)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    created_at = models.DateTimeField(auto_now_add=True)

Apply Migrations to Create the Database Table

python manage.py makemigrations
python manage.py migrate

Create a Superuser for Admin Panel

python manage.py createsuperuser

Visit http://127.0.0.1:8000/admin/ to manage the database using Django’s built-in admin panel.

6️⃣ Django Views & Routing

Define a View in views.py

from django.http import HttpResponse

def home(request):
    return HttpResponse("Hello, Django! 🎉")

Define a URL Pattern in urls.py

from django.urls import path
from .views import home

urlpatterns = [
    path("", home),
]

Visit: http://127.0.0.1:8000/ Output: "Hello, Django!

7️⃣ Django Templates – Rendering HTML

Create a Template (templates/home.html)

<!DOCTYPE html>
<html>
<head>
    <title>Django App</title>
</head>
<body>
    <h1>Welcome to Django!</h1>
</body>
</html>

Modify views.py to Use Templates

from django.shortcuts import render

def home(request):
    return render(request, "home.html")

Now your Django app can render HTML pages dynamically!

PreviousWeb3.JSNextGoLang

Last updated 3 months ago

Was this helpful?