Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
정경업
committed
Feb 4, 2015
1 parent
148b4de
commit 22595aa
Showing
3 changed files
with
10 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.shortcuts import render, get_object_or_404 | ||
from django.views.generic import ListView, DetailView | ||
|
||
from blog.models import Post | ||
|
||
|
||
def home(request): | ||
class PostList(ListView): | ||
model = Post | ||
template_name = 'home.html' | ||
posts = Post.objects.all() | ||
context_data = {'object_list': posts} | ||
return render(request, template_name, context_data) | ||
|
||
|
||
def detail(request, pk): | ||
class PostDetail(DetailView): | ||
model = Post | ||
template_name = 'detail.html' | ||
post = get_object_or_404(Post, id=pk) | ||
context_data = {'object': post} | ||
return render(request, template_name, context_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters