--- /dev/null
+.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;
+}
--- /dev/null
+{% load staticfiles %}
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Neil's 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>
\ No newline at end of file
--- /dev/null
+{% 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 %}
\ No newline at end of file
-<!DOCTYPE html>
-<html>
-<head>
- <title>Neil's blog</title>
-</head>
-<body>
-
-<div>
- <h1><a href="">Django Girls Blog</a></h1>
-</div>
+{% extends 'blog/base.html' %}
+{% block content %}
{% for post in posts %}
- <div>
- <p>Published: {{ post.published_date }}</p>
- <h1><a href="">{{ post.title }}</a></h1>
- <p>{{ post.text | linebreaksbr }}</p>
+<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>
{% endfor %}
-
-</body>
-</html>
\ No newline at end of file
+{% endblock %}
\ No newline at end of file
urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
+ url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'),
]
\ No newline at end of file
-from django.shortcuts import render
+from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from .models import Post
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})