-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added view and template for detailed blog post as well as CSS for the…
… site.
- Loading branch information
1 parent
fd7cd2d
commit 5c5e217
Showing
6 changed files
with
101 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.page-header { | ||
background-color: #ff9400; | ||
margin-top: 0; | ||
padding: 20px 20px 20px 40px; | ||
} | ||
|
||
.page-header h1, .page-header h1 a, .page-header h1 a:visited, .page-header h1 a:active { | ||
color: #ffffff; | ||
font-size: 36pt; | ||
text-decoration: none; | ||
} | ||
|
||
.content { | ||
margin-left: 40px; | ||
} | ||
|
||
h1, h2, h3, h4 { | ||
font-family: 'Lobster', cursive; | ||
} | ||
|
||
.date { | ||
color: #828282; | ||
} | ||
|
||
.save { | ||
float: right; | ||
} | ||
|
||
.post-form textarea, .post-form input { | ||
width: 100%; | ||
} | ||
|
||
.top-menu, .top-menu:hover, .top-menu:visited { | ||
color: #ffffff; | ||
float: right; | ||
font-size: 26pt; | ||
margin-right: 20px; | ||
} | ||
|
||
.post { | ||
margin-bottom: 70px; | ||
} | ||
|
||
.post h1 a, .post h1 a:visited { | ||
color: #000000; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{% load staticfiles %} | ||
<html> | ||
<head> | ||
<title>Django Girls blog</title> | ||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"> | ||
<link href='//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext' rel='stylesheet' type='text/css'> | ||
<link rel="stylesheet" href="{% static 'css/blog.css' %}"> | ||
</head> | ||
|
||
<body> | ||
<div class="page-header"> | ||
<h1><a href="/">Django Girls Blog</a></h1> | ||
</div> | ||
<div class="content container"> | ||
<div class="row"> | ||
<div class="col-md-8"> | ||
{% block content %} | ||
{% endblock %} | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% extends 'blog/base.html' %} | ||
|
||
{% block content %} | ||
<div class="post"> | ||
{% if post.published_date %} | ||
<div class="date"> | ||
{{ post.published_date }} | ||
</div> | ||
{% endif %} | ||
<h1>{{ post.title }}</h1> | ||
<p>{{ post.text|linebreaksbr }}</p> | ||
</div> | ||
{% endblock %} |
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,24 +1,13 @@ | ||
<html> | ||
<head> | ||
<title>Django Girls blog</title> | ||
</head> | ||
<body> | ||
<div> | ||
<h1><a href="/">Django Girls Blog</a></h1> | ||
</div> | ||
|
||
{% for post in posts %} | ||
<div> | ||
<p>published: {{ post.published_date }}</p> | ||
<h1><a href="">{{ post.title }}</a></h1> | ||
<p>{{ post.text|linebreaksbr }}</p> | ||
</div> | ||
{% endfor %} | ||
{% extends 'blog/base.html' %} | ||
|
||
<div> | ||
<p>published: 14.06.2014, 12:14</p> | ||
<h2><a href="">My second post</a></h2> | ||
<p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut f.</p> | ||
{% block content %} | ||
{% for post in posts %} | ||
<div class="post"> | ||
<div class="date"> | ||
<p>published: {{ post.published_date }}</p> | ||
</div> | ||
<h1><a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a></h1> | ||
<p>{{ post.text|linebreaksbr }}</p> | ||
</div> | ||
</body> | ||
</html> | ||
{% endfor %} | ||
{% endblock %} |
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,8 +1,13 @@ | ||
from django.shortcuts import render | ||
from django.shortcuts import render, get_object_or_404 | ||
from django.utils import timezone | ||
from .models import Post | ||
|
||
|
||
# Create your views here. | ||
def post_list(request): | ||
posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') | ||
return render(request, 'blog/post_list.html', {'posts':posts}) | ||
|
||
def post_detail(request, pk): | ||
post = get_object_or_404(Post, pk=pk) | ||
return render(request, 'blog/post_detail.html', {'post': post}) |