diff options
| author | Bobby <[email protected]> | 2022-11-14 06:53:18 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2022-11-14 06:53:18 -0500 |
| commit | 324d3acfdf3cc024b2cc1edc721085448d36ccda (patch) | |
| tree | 24c9a161f3807609de2c6716e84c37ecb0fc0a6a | |
| parent | 85531d778d82da8dc9992e499bee7111958a554b (diff) | |
| download | thatcomputerscientist-324d3acfdf3cc024b2cc1edc721085448d36ccda.tar.xz thatcomputerscientist-324d3acfdf3cc024b2cc1edc721085448d36ccda.zip | |
adding context processors and removing unneeded js
| -rw-r--r-- | blog/context_processors.py | 8 | ||||
| -rw-r--r-- | blog/views.py | 2 | ||||
| -rw-r--r-- | templates/blog/home.html | 7 | ||||
| -rw-r--r-- | thatcomputerscientist/settings.py | 2 |
4 files changed, 7 insertions, 12 deletions
diff --git a/blog/context_processors.py b/blog/context_processors.py index de9371ae..4df11416 100644 --- a/blog/context_processors.py +++ b/blog/context_processors.py @@ -6,10 +6,10 @@ def recent_posts(): post.excerpt = post.body.split('>')[1].split('<')[0] return recent_posts -def categories(): +def categories(request): categories = Category.objects.all() - return categories + return {'categories': categories} -def archives(): +def archives(request): archives = Post.objects.filter(is_public=True).dates('date', 'month', order='DESC') - return archives + return {'archives': archives} diff --git a/blog/views.py b/blog/views.py index 9fa95801..b514750a 100644 --- a/blog/views.py +++ b/blog/views.py @@ -18,7 +18,7 @@ from announcements.models import Announcement def home(request): announcements = Announcement.objects.filter(is_public=True).order_by('-created_at') announcements = announcements if len(announcements) > 0 else None - return render(request, 'blog/home.html', {'title': 'Home', 'recent_posts': recent_posts(), 'categories': categories(), 'archives': archives(), 'announcements': announcements}) + return render(request, 'blog/home.html', {'title': 'Home', 'recent_posts': recent_posts(), 'announcements': announcements}) def account(request): user = request.user diff --git a/templates/blog/home.html b/templates/blog/home.html index 02897092..802ed7b8 100644 --- a/templates/blog/home.html +++ b/templates/blog/home.html @@ -84,16 +84,9 @@ reading...</em > </p> - <br> </li> {% endfor %} </ul> - <script - src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/mml-chtml.min.js" - integrity="sha512-4JUXEJCjFmGygcGTR/doRQ1Kw7uEYn+kBpiGWyVBzUQHtFSPQNm08E/lqo2/XJqiWKKV0nTpv1q8bHPPDL4n4Q==" - crossorigin="anonymous" - referrerpolicy="no-referrer" - ></script> {% endif %} </div> {% endblock %} diff --git a/thatcomputerscientist/settings.py b/thatcomputerscientist/settings.py index 8d95e329..b56f96f9 100644 --- a/thatcomputerscientist/settings.py +++ b/thatcomputerscientist/settings.py @@ -84,6 +84,8 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'blog.context_processors.categories', + 'blog.context_processors.archives', ], }, }, |
