当前位置:网站首页>Flask blog practice - realize the latest articles and search in the sidebar
Flask blog practice - realize the latest articles and search in the sidebar
2022-06-25 10:14:00 【Light programming】
Implement the latest article module
This is very simple , Just send the latest article into blog In the context of

stay app/blog/views.py Of inject_archive The new code in the function is as follows :
@bp.context_processor
def inject_archive():
# Article archive date injection context
posts = Post.query.order_by(Post.add_date)
dates = set([post.add_date.strftime("%Y year %m month ") for post in posts])
# label
tags = Tag.query.all()
for tag in tags:
tag.style = ['is-success', 'is-danger', 'is-black', 'is-light', 'is-primary', 'is-link', 'is-info', 'is-warning']
# The latest article
new_posts = posts.limit(6)
return dict(dates=dates, tags=tags, new_posts=new_posts)stay app/blog/templates/cate_list.html Add the following code to the sidebar of :
<div class="box is-shadow边栏推荐
- Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.
- Grabcut image segmentation in opencv
- 【动态规划】—— 数字三角形
- Learning notes of rxjs takeuntil operator
- Jetpack compose layout (II) - material components and layout
- Mengyou Technology: six elements of tiktok's home page decoration, how to break ten thousand dollars in three days
- How to make a self-service order wechat applet? How to do the wechat order applet? visual editing
- Redis(二)分布式锁与Redis集群搭建
- Mqtt beginner level chapter
- Oracle查询自带JDK版本
猜你喜欢

Rxjs TakeUntil 操作符的学习笔记

独步武林,架构选型手册(包含 PDF)

MongoDB的原理、基本使用、集群和分片集群

Jetpack compose layout (I) - basic knowledge of layout

Linked list delete nodes in the linked list

Redis(二)分布式锁与Redis集群搭建

Vscode attempted to write the procedure to a pipeline that does not exist

How to "transform" small and micro businesses (I)?

How to apply for a widget on wechat how to get a widget on wechat

Exception: gradle task assemblydebug failed with exit code 1
随机推荐
MySQL创建给出语句
SQL to object thinking vs SQL of object thinking
What should be paid attention to in PMP examination?
我希望按照我的思路尽可能将canvas基础讲明白
ShardingSphere-Proxy 5.0 分库分表(一)
在Microsoft Exchange Server 2007中安装SSL证书的教程
Bitmap is converted into drawable and displayed on the screen
【论文阅读|深读】DRNE:Deep Recursive Network Embedding with Regular Equivalence
Webapi performance optimization
Guiding principle - read source code
Kotlin common standard functions
Get started quickly with jetpack compose Technology
JS【中高级】部分的知识点我帮你们总结好了
Use evo
How to do the wechat selling applet? How to apply for applets
Identityserver4 definition concept
Mongodb's principle, basic use, clustering and partitioned clustering
Oracle query comes with JDK version
Basic usage and principle of schedulemaster distributed task scheduling center
Difference between malloc and calloc