シリーズ #1
10記事
Django 5入門チュートリアル|実践ブログ開発で学ぶWeb開発
Django 5を使った実践的なブログアプリ開発チュートリアル。初心者でも基礎から応用まで体系的に学べます。
約671分
2025/06/15
PythonDjangoWeb開発
学習開始
$ yarn dev --turbopack▲ Next.js 15.3.1- Local: http://localhost:3000import { getAllPosts } from './lib/markdown'import PostCard from './components/PostCard'export default async function Home() {const posts = await getAllPosts()return (<main className='max-w-4xl mx-auto'>{posts.map(post => (<PostCard key={post.id} post={post} />))}</main>)}$ git add -A$ git commit -m 'feat: add blog posts'[main abc1234] feat: add blog posts3 files changed, 142 insertions(+)$ yarn dev --turbopack▲ Next.js 15.3.1- Local: http://localhost:3000import { getAllPosts } from './lib/markdown'import PostCard from './components/PostCard'export default async function Home() {const posts = await getAllPosts()return (<main className='max-w-4xl mx-auto'>{posts.map(post => (<PostCard key={post.id} post={post} />))}</main>)}$ git add -A$ git commit -m 'feat: add blog posts'[main abc1234] feat: add blog posts3 files changed, 142 insertions(+)$ yarn dev --turbopack▲ Next.js 15.3.1- Local: http://localhost:3000import { getAllPosts } from './lib/markdown'import PostCard from './components/PostCard'export default async function Home() {const posts = await getAllPosts()return (<main className='max-w-4xl mx-auto'>{posts.map(post => (<PostCard key={post.id} post={post} />))}</main>)}$ git add -A$ git commit -m 'feat: add blog posts'[main abc1234] feat: add blog posts3 files changed, 142 insertions(+)
package mainimport ("fmt""net/http""encoding/json")type Article struct {ID int `json:"id"`Title string `json:"title"`Body string `json:"body"`}func getArticles(w http.ResponseWriter,r *http.Request) {articles := fetchAll()json.NewEncoder(w).Encode(articles)}$ go run main.goServer listening on :8080$ docker compose up -d✓ Container postgres started✓ Container redis started✓ Container app startedpackage mainimport ("fmt""net/http""encoding/json")type Article struct {ID int `json:"id"`Title string `json:"title"`Body string `json:"body"`}func getArticles(w http.ResponseWriter,r *http.Request) {articles := fetchAll()json.NewEncoder(w).Encode(articles)}$ go run main.goServer listening on :8080$ docker compose up -d✓ Container postgres started✓ Container redis started✓ Container app startedpackage mainimport ("fmt""net/http""encoding/json")type Article struct {ID int `json:"id"`Title string `json:"title"`Body string `json:"body"`}func getArticles(w http.ResponseWriter,r *http.Request) {articles := fetchAll()json.NewEncoder(w).Encode(articles)}$ go run main.goServer listening on :8080$ docker compose up -d✓ Container postgres started✓ Container redis started✓ Container app started
use axum::{Router, Json, extract::State};use serde::{Deserialize, Serialize};#[derive(Serialize, Deserialize)]struct Post {id: i32,title: String,published: bool,}async fn list_posts(State(pool): State<PgPool>,) -> Json<Vec<Post>> {let posts = sqlx::query_as("SELECT * FROM posts").fetch_all(&pool).await.unwrap();Json(posts)}$ cargo run --releaseCompiling blog-api v0.1.0Finished release [optimized]Running `target/release/blog-api`listening on 0.0.0.0:3000use axum::{Router, Json, extract::State};use serde::{Deserialize, Serialize};#[derive(Serialize, Deserialize)]struct Post {id: i32,title: String,published: bool,}async fn list_posts(State(pool): State<PgPool>,) -> Json<Vec<Post>> {let posts = sqlx::query_as("SELECT * FROM posts").fetch_all(&pool).await.unwrap();Json(posts)}$ cargo run --releaseCompiling blog-api v0.1.0Finished release [optimized]Running `target/release/blog-api`listening on 0.0.0.0:3000use axum::{Router, Json, extract::State};use serde::{Deserialize, Serialize};#[derive(Serialize, Deserialize)]struct Post {id: i32,title: String,published: bool,}async fn list_posts(State(pool): State<PgPool>,) -> Json<Vec<Post>> {let posts = sqlx::query_as("SELECT * FROM posts").fetch_all(&pool).await.unwrap();Json(posts)}$ cargo run --releaseCompiling blog-api v0.1.0Finished release [optimized]Running `target/release/blog-api`listening on 0.0.0.0:3000
$ python manage.py runserverWatching for file changes...Starting development server athttp://127.0.0.1:8000/from django.db import modelsclass Article(models.Model):title = models.CharField(max_length=200)content = models.TextField()published = models.BooleanField()created_at = models.DateTimeField(auto_now_add)def __str__(self):return self.title$ pytest -vtests/test_api.py::test_get_posts PASSEDtests/test_api.py::test_create_post PASSEDtests/test_auth.py::test_login PASSED========= 3 passed in 0.42s =========$ python manage.py runserverWatching for file changes...Starting development server athttp://127.0.0.1:8000/from django.db import modelsclass Article(models.Model):title = models.CharField(max_length=200)content = models.TextField()published = models.BooleanField()created_at = models.DateTimeField(auto_now_add)def __str__(self):return self.title$ pytest -vtests/test_api.py::test_get_posts PASSEDtests/test_api.py::test_create_post PASSEDtests/test_auth.py::test_login PASSED========= 3 passed in 0.42s =========$ python manage.py runserverWatching for file changes...Starting development server athttp://127.0.0.1:8000/from django.db import modelsclass Article(models.Model):title = models.CharField(max_length=200)content = models.TextField()published = models.BooleanField()created_at = models.DateTimeField(auto_now_add)def __str__(self):return self.title$ pytest -vtests/test_api.py::test_get_posts PASSEDtests/test_api.py::test_create_post PASSEDtests/test_auth.py::test_login PASSED========= 3 passed in 0.42s =========
const [theme, setTheme] = useState('dark')const [query, setQuery] = useState('')useEffect(() => {const saved = localStorage.getItem('theme')if (saved) setTheme(saved)}, [])async function fetchData(endpoint: string) {const res = await fetch(endpoint)if (!res.ok) throw new Error(res.statusText)return res.json()}interface Post {id: stringtitle: stringdate: stringtags: string[]}$ kubectl get podsNAME READY STATUSblog-api-7d4f8 1/1 Runningblog-web-3a2b1 1/1 Runningconst [theme, setTheme] = useState('dark')const [query, setQuery] = useState('')useEffect(() => {const saved = localStorage.getItem('theme')if (saved) setTheme(saved)}, [])async function fetchData(endpoint: string) {const res = await fetch(endpoint)if (!res.ok) throw new Error(res.statusText)return res.json()}interface Post {id: stringtitle: stringdate: stringtags: string[]}$ kubectl get podsNAME READY STATUSblog-api-7d4f8 1/1 Runningblog-web-3a2b1 1/1 Runningconst [theme, setTheme] = useState('dark')const [query, setQuery] = useState('')useEffect(() => {const saved = localStorage.getItem('theme')if (saved) setTheme(saved)}, [])async function fetchData(endpoint: string) {const res = await fetch(endpoint)if (!res.ok) throw new Error(res.statusText)return res.json()}interface Post {id: stringtitle: stringdate: stringtags: string[]}$ kubectl get podsNAME READY STATUSblog-api-7d4f8 1/1 Runningblog-web-3a2b1 1/1 Running
基礎から実践まで段階的に学べるチュートリアルで、確実なスキルアップを実現できます
新しい知識と技術トレンドをお届けしています