pixabay https://cdn.pixabay.com/photo/2019/05/14/17/07/web-development-4202909_1280.png https://steempeak.com/hive-101145/@june0620/python-12-django-5-template-tags-filters 이 글에서도 언급했던 7일 전 포스팅 보상이 0으로 노출되는 문제를 해결해 본다. pending_payout_value 값을 썼는데 7일전 포스팅은 이미 보상이 완료됐기때문에 해당 키값이 0으로 되면서 발생한 문제였다. get_blog 함수 리스폰스 값을 확인 결과 7일전 보상은 total_payout_value 를 쓰면 될 것 같다. `pending_payout_value값이 있으면 사용, 0이면 total_payout_value 값 사용`을 django의 templatetags.py 에 filter로 등록하면 될 것 같다. ``` @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 파일도 이 filter를 사용하여 조금 수정해 줘야 한다. ``` ... <small class="text-muted">보상 {{ post.comment | get_payout_value }} </small> ... ```  *** **[Cookie 😅]** Python 3.7.4 Django 2.2.4 steem-python 1.0.1 goorm IDE 1.3 참고 글: https://wayhome25.github.io/django/2017/06/22/custom-template-filter/ https://www.pymoon.com/entry/djang-%ED%85%9C%ED%94%8C%EB%A6%BF%EC%97%90%EC%84%9C-custom-tag-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0 https://amoreopensource.wordpress.com/2019/04/23/access-jsonfield-in-django-templates-like-a-dictionary/
author | june0620 |
---|---|
permlink | python-16-django-9-7-0-qg4vnv |
category | hive-132971 |
json_metadata | {"app":"peakd/2020.08.3","format":"markdown","tags":["kr","mini","dblog","dev","django","whalepower","palnet","steempython"],"users":["june0620","register.filter"],"links":["https://steempeak.com/hive-101145/@june0620/python-12-django-5-template-tags-filters","https://wayhome25.github.io/django/2017/06/22/custom-template-filter/","https://www.pymoon.com/entry/djang-%ED%85%9C%ED%94%8C%EB%A6%BF%EC%97%90%EC%84%9C-custom-tag-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0","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"]} |
created | 2020-09-04 12:21:30 |
last_update | 2020-09-04 12:21:30 |
depth | 0 |
children | 0 |
last_payout | 2020-09-11 12:21:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.813 HBD |
curator_payout_value | 0.739 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,305 |
author_reputation | 118,592,211,436,406 |
root_title | "[Python #16] [Django #9] 7일전 보상 0으로 노출되는 문제 해결" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 0 |
post_id | 99,445,381 |
net_rshares | 6,444,947,354,033 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
slowwalker | 0 | 53,279,477,998 | 50% | ||
livingfree | 0 | 307,304,086,285 | 4% | ||
ace108 | 0 | 276,553,279,467 | 7% | ||
tumutanzi | 0 | 922,973,728 | 50% | ||
oldstone | 0 | 17,783,456,430 | 50% | ||
dylanhobalart | 0 | 60,689,535,290 | 21% | ||
created | 0 | 729,525,010,446 | 4% | ||
coldhair | 0 | 889,382,391 | 50% | ||
lotusofmymom | 0 | 467,593,765 | 50% | ||
alphacore | 0 | 9,406,395,898 | 0.65% | ||
shenchensucc | 0 | 17,687,023,148 | 30% | ||
khaiyoui | 0 | 410,917,565,555 | 20% | ||
tookta | 0 | 174,714,558,602 | 50% | ||
kimzwarch | 0 | 8,719,826,021 | 4% | ||
june0620 | 0 | 528,429,985,538 | 100% | ||
minloulou | 0 | 2,331,595,615 | 10% | ||
lindalex | 0 | 578,300,667 | 50% | ||
cnbuddy | 0 | 925,846,700,885 | 100% | ||
itchyfeetdonica | 0 | 50,615,026,557 | 50% | ||
nokodemion | 0 | 8,453,173,864 | 100% | ||
mmmmkkkk311 | 0 | 282,950,912,937 | 3.5% | ||
suhunter | 0 | 958,613,545 | 50% | ||
udabeu | 0 | 9,725,576,224 | 30% | ||
jsj1215 | 0 | 3,760,464,478 | 100% | ||
futurecurrency | 0 | 25,894,036,052 | 40% | ||
realprince | 0 | 30,486,185,828 | 100% | ||
gghite | 0 | 188,087,293,773 | 100% | ||
julialee66 | 0 | 1,101,644,542,878 | 8.5% | ||
andrewma | 0 | 11,958,460,405 | 50% | ||
wisdomandjustice | 0 | 1,136,789,437 | 50% | ||
meins0815 | 0 | 11,464,960,960 | 23% | ||
crimo | 0 | 618,923,001 | 11.5% | ||
coder-bts | 0 | 4,903,086,129 | 50% | ||
daath | 0 | 587,364,920 | 100% | ||
veronicalee | 0 | 514,182,838 | 50% | ||
melaniewang | 0 | 8,593,075,231 | 50% | ||
changxiu | 0 | 5,036,748,008 | 50% | ||
bluengel | 0 | 15,996,648,970 | 100% | ||
laissez-faire | 0 | 78,280,767 | 100% | ||
cherryzz | 0 | 168,798,022,563 | 50% | ||
forecasteem | 0 | 72,272,772,488 | 100% | ||
moneytron | 0 | 5,414,761,144 | 100% | ||
ctime | 0 | 775,130,063,055 | 5% | ||
cpt-sparrow | 0 | 3,391,823,548 | 100% | ||
tina3721 | 0 | 4,849,597,624 | 50% | ||
andyhsia | 0 | 7,708,846,091 | 100% | ||
oldstone.sct | 0 | 554,913,113 | 50% | ||
tokenindustry | 0 | 2,776,771,749 | 80% | ||
hongdangmu | 0 | 552,649,605 | 8.5% | ||
mein2070 | 0 | 2,706,268,673 | 75% | ||
cnbuddy-reward | 0 | 76,997,400,810 | 100% | ||
roseofmylife | 0 | 2,686,379,622 | 50% | ||
real3earch | 0 | 9,240,846,795 | 100% | ||
steem-agora | 0 | 11,137,740,895 | 50% | ||
toni.pal | 0 | 0 | 0.62% | ||
hiveyoda | 0 | 10,283,172,600 | 4% | ||
blogstats | 0 | 934,229,127 | 100% |