This commit is contained in:
Anna Sudnitsina 2017-11-13 21:12:12 +03:00
parent d0a960ebb2
commit d749021b7a
3 changed files with 21 additions and 12 deletions

View File

@ -1,4 +1,5 @@
a {
a {
color: #4a809a;
}
body{
@ -223,10 +224,16 @@ a {
background-color: rgba(41, 128, 185, 0.1);
}
#plus {display: none;}
@media screen and (max-width: 900px) {
#posts {padding: 0}
#header {width: 98%;}
#header {width: 100%;}
//.sidemenu {background: #F7F7F8;}
#search, .sidemenu {display: none}
}
#plus {color: #FFF; float: right;
font-size: 25px;
display: block;
//height: 30px;
margin: 12px;
}
}

View File

@ -3,10 +3,10 @@
<html>
<head>
<title>BLOG</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{% static 'css/blog.css' %}">
<link rel="stylesheet" href="{% static 'css/new.css' %}">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>
@ -18,6 +18,8 @@
<input id="button-search" type="submit" value=""></input>
</form>
</div>
<a href="{% url 'post_new' %}"><i id="plus" class="fa fa-plus-square"></i></a>
</div>
<div id="content">
<div id="posts">
@ -42,13 +44,13 @@
{% endfor %}
</ul>
</div>
<div class="block">
<div class="block" style="text-align: center">
<h2> Теги </h2>
<ul>
{% for tag in tags %}
<li><li><a href="{% url 'post_list' tag=tag %}">{{ tag.name }} : {{ tag.c }}</a></li>
<a href="{% url 'post_list' tag=tag %}" style="font-size: {{tag.f}}; margin: 2px ">{{ tag.name }}({{ tag.c }})</a>
{% endfor %}
</ul>
</div>
</div>

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django.shortcuts import render
from .models import Post
from django.db.models import Count, Q
from django.db.models import Count, Max, Min, Q
from django.utils import timezone
from django.shortcuts import render, get_object_or_404, render_to_response
from django.shortcuts import redirect
@ -20,7 +20,7 @@ def post_list(request, page='1', tag=None):
paginator = Paginator(post_list, 5)
page = request.GET.get('page')
latest = Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')[0:9]
tags = Tag.objects.all().annotate(c = Count('post'))
tags = Tag.objects.all().annotate(c = Count('post'), f=Count('post')**(1/1.05)+12).filter(c__gt = 0).order_by('name')
try:
posts = paginator.page(page)
except PageNotAnInteger: # If page is not an integer, deliver first page.