forked from yahyaaly151989/Mastering_Django
-
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.
- Loading branch information
1 parent
6c4e429
commit 1020e90
Showing
9 changed files
with
152 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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,92 @@ | ||
body { | ||
margin:0; | ||
padding:0; | ||
font-family:helvetica, sans-serif; | ||
} | ||
|
||
a { | ||
color:#00abff; | ||
text-decoration:none; | ||
} | ||
|
||
h1 { | ||
font-weight:normal; | ||
border-bottom:1px solid #bbb; | ||
padding:0 0 10px 0; | ||
} | ||
|
||
h2 { | ||
font-weight:normal; | ||
margin:30px 0 0; | ||
} | ||
|
||
#content { | ||
float:left; | ||
width:60%; | ||
padding:0 0 0 30px; | ||
} | ||
|
||
#sidebar { | ||
float:right; | ||
width:30%; | ||
padding:10px; | ||
background:#efefef; | ||
height:100%; | ||
} | ||
|
||
p.date { | ||
color:#ccc; | ||
font-family: georgia, serif; | ||
font-size: 12px; | ||
font-style: italic; | ||
} | ||
|
||
/* pagination */ | ||
.pagination { | ||
margin:40px 0; | ||
font-weight:bold; | ||
} | ||
|
||
/* forms */ | ||
label { | ||
float:left; | ||
clear:both; | ||
color:#333; | ||
margin-bottom:4px; | ||
} | ||
input, textarea { | ||
clear:both; | ||
float:left; | ||
margin:0 0 10px; | ||
background:#ededed; | ||
border:0; | ||
padding:6px 10px; | ||
font-size:12px; | ||
} | ||
input[type=submit] { | ||
font-weight:bold; | ||
background:#00abff; | ||
color:#fff; | ||
padding:10px 20px; | ||
font-size:14px; | ||
text-transform:uppercase; | ||
} | ||
.errorlist { | ||
color:#cc0033; | ||
float:left; | ||
clear:both; | ||
padding-left:10px; | ||
} | ||
|
||
/* comments */ | ||
.comment { | ||
padding:10px; | ||
} | ||
.comment:nth-child(even) { | ||
background:#efefef; | ||
} | ||
.comment .info { | ||
font-weight:bold; | ||
font-size:12px; | ||
color:#666; | ||
} |
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,19 @@ | ||
{% load static %} | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>{% block title %}{% endblock %}</title> | ||
<link href="{% static "css/blog.css" %}" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<div id="content"> | ||
{% block content %} | ||
{% endblock %} | ||
</div> | ||
<div id="sidebar"> | ||
<h2>My blog</h2> | ||
<p>This is my blog.</p> | ||
</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,11 @@ | ||
{% extends "blog/base.html" %} | ||
|
||
{% block title %}{{ post.title }}{% endblock %} | ||
|
||
{% block content %} | ||
<h1>{{ post.title }}</h1> | ||
<p class="date"> | ||
Published {{ post.publish }} by {{ post.author }} | ||
</p> | ||
{{ post.body|linebreaks }} | ||
{% 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% extends "blog/base.html" %} | ||
|
||
{% block title %}My Blog{% endblock %} | ||
|
||
{% block content %} | ||
<h1>My Blog</h1> | ||
{% for post in posts %} | ||
<h2> | ||
<a href="{% url 'blog:post_detail' post.id %}"> | ||
{{ post.title }} | ||
</a> | ||
</h2> | ||
<p class="date"> | ||
Published {{ post.publish }} by {{ post.author }} | ||
</p> | ||
{{ post.body|truncatewords:30|linebreaks }} | ||
<hr /> | ||
{% 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,3 +1,10 @@ | ||
from django.shortcuts import render | ||
from django.shortcuts import render, get_object_or_404 | ||
from .models import Post | ||
|
||
# Create your views here. | ||
def post_list(request): | ||
posts = Post.objects.all() | ||
return render(request, 'blog/post/list.html', {'posts': posts}) | ||
|
||
def post_detail(request, id): | ||
post = get_object_or_404(Post, id=id, status=Post.Status.PUBLISHED) | ||
return render(request, 'blog/post/detail.html', {'post': post}) |
Binary file not shown.