create account

[Python #16] [Django #9] 修改漏洞,7日前的文章收益显示为0的问题。 by june0620

View this thread on: hive.blogpeakd.comecency.com
· @june0620 ·
$1.74
[Python #16] [Django #9] 修改漏洞,7日前的文章收益显示为0的问题。
pixabay
https://cdn.pixabay.com/photo/2019/05/14/17/07/web-development-4202909_1280.png

https://peakd.com/hive-105017/@june0620/python-12-django-5-template-tags-filters 在这个帖子的最后一个图片可以看出,7日前的收益都显示0了,当然这不是区块链的问题,是我的问题啦。

我在网页显示收益值是用 pending_payout_value 值,但帖子过7日这个值便会变成0。
再看了看 get_blog 函数,7日前的帖子可以用 total_payout_value 应该就OK👌了。 


把`若 pending_payout_value 没有值改用 total_payout_value 值`这个放到 django 的 templatetags.py 文件里,注册过滤器应该没问题了。

```
@register.filter
def get_payout_value(post_data: dict):
    value = post_data['pending_payout_value']
    if value.startswith("0.000"):
        value = post_data['total_payout_value']
    return value
```

html 文件也改用上述过滤器,成功了~ 😄 
```
...
<small class="text-muted">보상 {{ post.comment | get_payout_value }} </small>
...
```

![](https://cdn.steemitimages.com/DQmaySZF3ebUuo67LKNzqFp2Z7PxULgjZgTUQtYXAbnbTAq/image.png)
***

**[Cookie 😅]**
Python 3.7.4
Django 2.2.4
steem-python 1.0.1
goorm IDE 1.3

参考文章:

https://amoreopensource.wordpress.com/2019/04/23/access-jsonfield-in-django-templates-like-a-dictionary/
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 4 others
properties (23)
authorjune0620
permlinkpython-16-django-9-7-0
categoryhive-105017
json_metadata{"app":"peakd/2020.08.3","format":"markdown","tags":["cn","dblog","dev","django","whalepower","palnet","python"],"users":["june0620","register.filter"],"links":["https://peakd.com/hive-105017/@june0620/python-12-django-5-template-tags-filters","https://amoreopensource.wordpress.com/2019/04/23/access-jsonfield-in-django-templates-like-a-dictionary/"],"image":["https://cdn.pixabay.com/photo/2019/05/14/17/07/web-development-4202909_1280.png","https://cdn.steemitimages.com/DQmaySZF3ebUuo67LKNzqFp2Z7PxULgjZgTUQtYXAbnbTAq/image.png"]}
created2020-09-03 12:24:21
last_update2020-09-03 12:24:21
depth0
children2
last_payout2020-09-10 12:24:21
cashout_time1969-12-31 23:59:59
total_payout_value0.930 HBD
curator_payout_value0.806 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,040
author_reputation118,592,211,436,406
root_title"[Python #16] [Django #9] 修改漏洞,7日前的文章收益显示为0的问题。"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id99,427,269
net_rshares7,412,052,783,483
author_curate_reward""
vote details (68)
@annepink ·
@tipu curate
properties (22)
authorannepink
permlinkqg31b7
categoryhive-105017
json_metadata{"users":["tipu"],"app":"hiveblog/0.1"}
created2020-09-03 12:28:24
last_update2020-09-03 12:28:24
depth1
children1
last_payout2020-09-10 12:28:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length12
author_reputation1,032,301,773,928,016
root_title"[Python #16] [Django #9] 修改漏洞,7日前的文章收益显示为0的问题。"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,427,331
net_rshares0
@tipu ·
<a href="https://tipu.online/hive_curator?annepink" target="_blank">Upvoted  &#128076;</a> (Mana: 24/32)
properties (22)
authortipu
permlinkre-qg31b7-20200903t122830
categoryhive-105017
json_metadata""
created2020-09-03 12:28:36
last_update2020-09-03 12:28:36
depth2
children0
last_payout2020-09-10 12:28:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length104
author_reputation55,928,170,249,518
root_title"[Python #16] [Django #9] 修改漏洞,7日前的文章收益显示为0的问题。"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id99,427,334
net_rshares0