This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
2 changed files
with
5 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
from django.shortcuts import render, get_object_or_404 | ||
from blog.models import Post | ||
|
||
# Create your views here. | ||
|
||
#returns a dictionary with a list of the last 2 Blog Posts | ||
def homeBlog(): | ||
pst = Post.objects.order_by('-published_date')[:2] | ||
return ({'posts': pst}) | ||
|
||
#loads the blog page with posts ordered by date ( most recent first) | ||
def blog(request): | ||
posts = Post.objects.order_by('-published_date') | ||
return render(request, 'blog/blog.html', {'posts':posts}) | ||
|
||
#renders the Blog Post page | ||
def blogPost(request, pk): | ||
post = get_object_or_404(Post, pk=pk) | ||
return render(request, 'blog/blogPost.html', {'post':post}) |
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