A practical JWT auth playbook for Django with TypeScript SPAs Features JWT Header Access, Cookie Refresh
This guide documents a battle‑tested pattern for web apps where the frontend is rendered by Django templates (or any SPA) and calls a REST API secured by JWTs. It assumes mainstream web‑app threat models and focuses on staying resilient against XSS and CSRF while keeping the UX smooth. Jwt Auth Playbook — Django + Type Script (header Access, Cookie Refresh)
“Header Access, Cookie Refresh — A practical JWT auth playbook for Django + TypeScript SPAs.” It covers:
- Architecture & threat model
- Exact cookie/CORS/CSRF settings to use
- Backend endpoint contracts (login/refresh/logout)
- Frontend behavior (single-flight refresh, one-retry rule, per-tab storage)
- Security headers (CSP, etc.), ops hygiene, tests, pitfalls, and a print-ready checklist
Polls Project Django App: Models, Migrations & Admin, Part 2
Build Your First Django App: Models, Migrations & Admin. We'll walk through each concept clearly — from configuring your database to defining data structures using Django models. You'll learn how to generate and apply migrations, use Django's built-in ORM to interact with your data, and activate the admin interface for easy data management. Whether you're just experimenting or preparing for real-world app development, this guide offers the practical knowledge you need to progress confidently.
What This Article Will Cover
➡️ How to configure your Django project’s database
➡️ Creating and activating Django models
➡️ Generating and applying migrations
➡️ Using Django’s ORM for database interaction
➡️ Connecting your app to Django admin
➡️ Running queries in the interactive shell
➡️ Best practices for model and migration management
➡️ Using Django’s ORM for database interaction
➡️ Running queries in the interactive shell
➡️ Creating and activating Django models
➡️ Update TIME_ZONE to your region
➡️ Ensure INSTALLED_APPS
Polls Project: Build Your First Django App, Part 1
Let’s learn by creating an app. Throughout this tutorial, we’ll walk you through the creation of a basic poll application. We'll guide you through each essential step, from installing Django and understanding the project structure to running your development server and wiring up your first views and URLs. Once you've got your first app running, we'll show you how to enhance it and what's next on your Django journey, including a more advanced library management system. Let's dive in and build something real!
Getting Started with Django: Install and Build Your First App
Django for Beginners: Setup, Tutorials, and First Project. If you’re looking to build dynamic, powerful web applications with Python, Django is one of the best frameworks you can start with. It’s fast, secure, and comes packed with features like authentication, admin panels, and an ORM (Object-Relational Mapping) system right out of the box. Whether you're a beginner exploring web development or a developer transitioning from other frameworks, Django offers a structured path to success. In this guide, we’ll walk you through how to get started with Django step by step — from installation to running your first project using the official tutorial. By the end, you'll have Django installed and your very first web app up and running. We’ll also link to key resources to help you continue your learning journey and explore Django’s powerful capabilities. Let’s dive in!
When and Why to Use Django's Sites Framework (SITE_ID=1)
In Django, the Site framework (with site_id=1) is part of the django.contrib.sites framework. It allows for managing multiple web domains with a single Django project. Here's a breakdown of when and why you'd use it, and whether it's a good idea for your project: