diff options
| author | Bobby <[email protected]> | 2022-09-25 00:56:00 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-09-25 00:56:00 -0400 |
| commit | 3f2fc550a7baf7bbd8d9045d4f2e1bcf41a209ff (patch) | |
| tree | f016d6721144eb6a6de31d7ac5747393dea5e8b6 /blog | |
| parent | 46e0c0c700f3fc700952cbc9dad2f7e04719456b (diff) | |
| download | thatcomputerscientist-3f2fc550a7baf7bbd8d9045d4f2e1bcf41a209ff.tar.xz thatcomputerscientist-3f2fc550a7baf7bbd8d9045d4f2e1bcf41a209ff.zip | |
Major visual overhaul
Diffstat (limited to 'blog')
| -rw-r--r-- | blog/context_processors.py | 14 | ||||
| -rw-r--r-- | blog/views.py | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/blog/context_processors.py b/blog/context_processors.py index 605fc0c5..7d2f7da0 100644 --- a/blog/context_processors.py +++ b/blog/context_processors.py @@ -1,13 +1,13 @@ from .models import Post, Category -def recent_posts(request): - recent_posts = Post.objects.filter(is_public=True).order_by('-date')[:5] - return {'recent_posts': recent_posts} +def recent_posts(): + recent_posts = Post.objects.filter(is_public=True).order_by('-date')[1:6] + return recent_posts -def categories(request): +def categories(): categories = Category.objects.all() - return {'categories': categories} + return categories -def archives(request): +def archives(): archives = Post.objects.filter(is_public=True).dates('date', 'month', order='DESC') - return {'archives': archives} + return archives diff --git a/blog/views.py b/blog/views.py index 45db0370..28d693f1 100644 --- a/blog/views.py +++ b/blog/views.py @@ -10,12 +10,14 @@ from string import ascii_letters, digits import base64 import json from .models import Post, Comment +from .context_processors import recent_posts, categories, archives # Create your views here. def home(request): last_post = Post.objects.filter(is_public=True).order_by('-date')[0] - return render(request, 'blog/home.html', {'title': 'Home', 'last_post': last_post}) + first_paragraph = last_post.body.split('<p>')[1].split('</p>')[0] + return render(request, 'blog/home.html', {'title': 'Home', 'last_post': last_post, 'first_paragraph': first_paragraph, 'recent_posts': recent_posts(), 'categories': categories(), 'archives': archives()}) def account(request): user = request.user |
