当前位置:网站首页>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
边栏推荐
- js工具函数,自己封装一个节流函数
- Neat Syntax Design of an ETL Language (Part 2)
- Methodchannel of flutter
- Mengyou Technology: six elements of tiktok's home page decoration, how to break ten thousand dollars in three days
- Guiding principle - read source code
- Mengyou Technology: tiktok live broadcast with goods elements hot topics retention skills shaping image highlight selling points
- Rxjs TakeUntil 操作符的学习笔记
- Difference between malloc and calloc
- Houdini图文笔记:Your driver settings have been set to force 4x Antialiasing in OpenGL applications问题的解决
- Fluent: target support file /pods runner / pods runner frameworks Sh: permission denied - stack overflow
猜你喜欢
i++ 和 ++i的真正区别
2台三菱PLC走BCNetTCP协议,能否实现网口无线通讯?
Methodchannel of flutter
虚幻引擎图文笔记:使用VAT(Vertex Aniamtion Texture)制作破碎特效(Houdini,UE4/UE5)上 Houdini端
Download the arm64 package of Debian on X86 computer
字符串 最长公共前缀
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
Ruiji takeout project (II)
How to make small programs on wechat? How to make small programs on wechat
Flutter dialog: cupertinoalertdialog
随机推荐
Unique Wulin, architecture selection manual (including PDF)
What are the PMP scores?
js工具函数,自己封装一个节流函数
Consul的基本使用与集群搭建
Redis(一)原理与基本使用
Difference between malloc and calloc
2台三菱PLC走BCNetTCP协议,能否实现网口无线通讯?
DigiCert和GlobalSign单域名OV SSL证书对比评测
How do wechat sell small commodity programs do? How to open wechat apps to sell things?
依赖属性、依赖附加属性以及类型转换
字符串 最长公共前缀
Webapi performance optimization
[MySQL learning notes 22] index
Kotlin advanced generic
How to develop wechat applet? How to open a wechat store
【论文阅读|深读】LINE: Large-scale Information Network Embedding
Shardingsphere proxy 4.1 sub database and sub table
申请多域名SSL证书的要求及注意事项
Processing picture class library
JS tool function, self encapsulating a throttling function