当前位置:网站首页>[quantitative investment system]django realizes screening and paging from the database
[quantitative investment system]django realizes screening and paging from the database
2022-06-29 08:01:00 【Time. J】
**
Django Filtering data classification can only jump to the first page , Page 2 no data .
**
1.models.py Creating models
class User(models.Model):
uname= models.CharField(max_length=20)
uEmail= models.CharField(max_length=35)
uphone= models.CharField(max_length=15)
2.views.py Filter data from the database
if request.method == 'POST':
name = request.POST.get('code')
else:
name = request.GET.get('code')
UserList = User.objects.filter(uphone=name).order_by()
3. Pager
paginator = Paginator(UserList,2) # 3 posts in each page
page = request.GET.get('page')
try:
pagedata = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer deliver the first page
pagedata = paginator.page(1)
except EmptyPage:
# # If page is out of range deliver last page of results
pagedata = paginator.page(paginator.num_pages)
4. To transfer data
return (render(request,'Qt15606/students.html',{
'name':name,'page': pagedata,'pagedata': pagedata}))
5. Front end interface students.html
<div class="pagination">
<span class="step-links">
{
% if page.has_previous %}
<a style="font-weight:bold;color:#383957;" href="?page=1&code={
{name}}" > first page </a>
<a class="btn btn-primary btn-lg active" href="?page={
{page.previous_page_number}}&code={
{name}}"> The previous page </a>
{
% endif %}
<span style="font-weight:bold;color:#383957" class="current">
The first {
{
page.number}} page ··· common {
{
page.paginator.num_pages}} page
</span>
{
% if page.has_next %}
<a class="btn btn-primary btn-lg active" href="?page={
{page.next_page_number }}&code={
{name}}"> The next page </a>
<a class="btn btn-primary btn-lg active" href="?page={
{page.paginator.num_pages}}&code={
{name}}"> The last page </a>
{
% endif %}
</span>
</div>
The most important step is to add filter conditions to the links .href="?page={ {page.next_page_number }}&code={ {name}}"
边栏推荐
- AI deep dive of Huawei cloud
- 低配MySQL数据库几十秒插入百万数据
- 498. diagonal traversal (simulation)
- Basic syntax - bit operation
- [repair collection function, update login interface] knowledge payment applet, blog applet, full version open source code, resource realization applet, with 299 whole station resource data
- 多态中的向上和向下转型
- 基础语法 - 位运算
- 【量化投资系统】因子处理安装talib
- nor flash 应用层操作
- Segment tree and use
猜你喜欢

Electric check code configuration

穿越过后,她说多元宇宙真的存在

SizeBalanceTree
![[industrial control old horse] detailed explanation of design principle of pattern fountain based on PLC](/img/28/690f9985f32675f5d50d196c293abe.jpg)
[industrial control old horse] detailed explanation of design principle of pattern fountain based on PLC

SizeBalanceTree

VSLAM特征之线特征&面特征

Some examples.
![[old horse of industrial control] detailed explanation of Siemens PLC s7-300scl programming](/img/da/08f23cfe7f8759b73576eb0638fec5.png)
[old horse of industrial control] detailed explanation of Siemens PLC s7-300scl programming

C#Mqtt订阅消息

征文投稿丨使用轻量应用服务器搭建博客环境
随机推荐
Behaviortree in ros2
What are the organizational structure and job responsibilities of product managers in Internet companies?
MongoDB-使用mongo/mongosh命令行连接数据库
进程通信 - 管道
反思 - 完美主义
Oracle 批量插入数据-插入民族数据
MySQL系统关键字汇总(官网)
Should product managers learn from ink knife or Axure?
js异或混淆代码
SQL Server 开启cdc
AI and the meta universe sparked a spark: human beings lost only shackles and gained all-round liberation
qtcreator设置字符集
Selected Siemens PLC project example source code [300 sets in total]
Process communication - Pipeline
Handle series - install spotbugs and use them quickly
Thread pool operations in cartographer
SizeBalanceTree
Some examples.
C compiler - implicit function declaration
自动化测试 - uiautomator2框架应用 - 自动打卡