pixabay https://cdn.pixabay.com/photo/2019/05/14/17/07/web-development-4202909_1280.png 검색 기능에 UI를 추가한다. HTML의 form으로 우선 먼저 가볍게 구현해 보자. (깊게 구현할 능력도 안됨ㅎㅎ) ##### form 추가 먼저 django의 templates 폴더의 base.html 에 form 을 넣는다. 1. action은 일단 하드코딩으로 `/@june0620/search`로 한다. 계정명은 변수로 처리하고 싶은데 안된다. ㅠ (#연구필요#장고초자) 2. 검색 기능이니 method는 post보다는 get이 나을 것 같다. 3. input 태그 세 개를 만들고 각각 tags, titles, texts 레이블 추가한다. ``` <div> <p></p> <form action="/@june0620/search/" method="get"> <label >Tags: </label> <input id="tags" type="text" name="tags" value=""> <label >Titles: </label> <input id="titles" type="text" name="titles" value=""> <label >Texts: </label> <input id="texts" type="text" name="texts" value=""> <input type="submit" value="Search"> </form> </div> ``` <p>  <p> 대충 요런 화면인데 CSS가 없어서 이 모양이다. CSS 공부도 또 해야 하나? ㅠ 일단 기능에만 집중하자. 👇  ##### URL 설정 form의 action으로 받은 url을 urls.py에 설정한다. 이 부분은 변수를 사용할 줄 아니 변수로 처리하자. ㅎㅎ url 패턴과 매칭 될 경우 views.py의 SearchPosts 클래스를 호출한다. ``` path('@<slug:account>/search/', SearchPosts.as_view(), name='search'), ``` <p>  ##### form 파라미터 처리 및 검색 form 에서 전달받은 query string 을 리스트로 전환해야 하는데 split(',') 로 리스트화 및 query 딕셔너리에 추가한다. UI 단에서 동일 필드에 여러 개 검색어를 입력하고자 할 때 , 로 분리하면 더 많은 결과를 얻을 것이다. (일시적인 구현이고, 나중에 UI가 바뀌면 다시 구현 필요하다.) ``` class SearchPosts(ListView): template_name = 'album.html' context_object_name = 'all_posts' def get(self, request, *args, **kwargs): query = { 'tags': request.GET.get('tags').split(','), 'titles': request.GET.get('titles').split(','), 'texts': request.GET.get('texts').split(',') } se = Search(account=kwargs['account'], query=query) self.queryset = se.search_posts() return super().get(request, *args, **kwargs) ``` <p>  ##### 결과  <p>  **[Cookie 😅]** Python 3.7.4 Django 2.2.4 steem-python 1.0.1 goorm IDE 1.3
author | june0620 |
---|---|
permlink | python-17-django-10-ui |
category | hive-132971 |
json_metadata | {"app":"peakd/2020.08.3","format":"markdown","tags":["kr","whalepower","mini","palnet","steempython","python","dblog","dev","django","goorm"],"users":["june0620"],"image":["https://cdn.pixabay.com/photo/2019/05/14/17/07/web-development-4202909_1280.png","https://cdn.steemitimages.com/DQmaWkKn9ESkTtmMEDJWkTn3uZQE1zQD8kcndFCooB2u5rY/image.png","https://cdn.steemitimages.com/DQmNY5tjh5TGr4Nn7zP7dWZ4JY3L34iNeJ6oBz4KJANHRcx/image.png","https://cdn.steemitimages.com/DQmTFazmwMocShDKgQRAALGdC5ZhNkqJUckF89sp5EbvTsE/image.png","https://cdn.steemitimages.com/DQmXwXF9SubesEuRy2as37uPtcpywdzM7WxSyKrzhxm4pwe/image.png","https://cdn.steemitimages.com/DQmTMzFKPuTSGT6oSybGQiyzKaMe7nzfctm1VvrJX37b1wg/image.png","https://cdn.steemitimages.com/DQmQKXV7ckRC6jg4LXYw14i5kJ7raK1VSGrJGF27Rp9Uhw4/image.png"]} |
created | 2020-09-08 11:58:21 |
last_update | 2020-09-08 11:58:21 |
depth | 0 |
children | 1 |
last_payout | 2020-09-15 11:58:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.612 HBD |
curator_payout_value | 1.436 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,563 |
author_reputation | 118,592,211,436,406 |
root_title | "[Python #17] [Django #10] 검색 기능에 UI 추가" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 0 |
post_id | 99,516,841 |
net_rshares | 11,456,982,585,026 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
livingfree | 0 | 207,520,148,364 | 3% | ||
ace108 | 0 | 309,888,877,925 | 8% | ||
magicmonk | 0 | 2,505,650,105,592 | 100% | ||
tumutanzi | 0 | 926,146,203 | 50% | ||
discernente | 0 | 46,038,435 | 0.5% | ||
created | 0 | 499,855,166,581 | 3% | ||
coldhair | 0 | 892,445,338 | 50% | ||
centering | 0 | 1,745,650,210,544 | 100% | ||
alphacore | 0 | 9,189,648,169 | 0.52% | ||
shenchensucc | 0 | 16,932,702,851 | 30% | ||
techken | 0 | 31,153,507,783 | 50% | ||
khaiyoui | 0 | 414,525,860,321 | 20% | ||
kimzwarch | 0 | 9,271,413,845 | 4% | ||
june0620 | 0 | 572,282,731,267 | 100% | ||
mawit07 | 0 | 2,392,284,515 | 50% | ||
minloulou | 0 | 2,111,268,992 | 10% | ||
lindalex | 0 | 580,349,302 | 50% | ||
cnbuddy | 0 | 939,386,267,400 | 100% | ||
itchyfeetdonica | 0 | 111,832,105,068 | 50% | ||
nokodemion | 0 | 6,835,599,844 | 100% | ||
dudream | 0 | 57,945,901,145 | 100% | ||
bji1203 | 0 | 87,352,339,636 | 100% | ||
suhunter | 0 | 961,902,227 | 50% | ||
udabeu | 0 | 9,642,693,725 | 30% | ||
jsj1215 | 0 | 2,499,592,435 | 100% | ||
yasu | 0 | 5,082,602,902 | 100% | ||
futurecurrency | 0 | 25,314,310,790 | 40% | ||
realprince | 0 | 23,425,125,044 | 100% | ||
donekim | 0 | 2,680,332,526 | 100% | ||
lucky2015 | 0 | 5,562,549,620 | 100% | ||
gghite | 0 | 128,633,755,983 | 100% | ||
parkname | 0 | 234,977,472,883 | 100% | ||
payroll | 0 | 160,878,444,385 | 2% | ||
julialee66 | 0 | 1,107,704,032,358 | 8.5% | ||
andrewma | 0 | 11,335,340,124 | 50% | ||
meins0815 | 0 | 11,431,392,898 | 23% | ||
crimo | 0 | 593,692,485 | 11.5% | ||
newsnownorthwest | 0 | 6,884,566,303 | 100% | ||
coder-bts | 0 | 4,547,372,187 | 50% | ||
daath | 0 | 461,289,319 | 100% | ||
melaniewang | 0 | 8,123,692,724 | 50% | ||
changxiu | 0 | 5,053,333,843 | 50% | ||
bluengel | 0 | 13,310,152,980 | 100% | ||
laissez-faire | 0 | 46,108,941 | 100% | ||
cherryzz | 0 | 160,145,530,037 | 50% | ||
forecasteem | 0 | 65,144,609,447 | 100% | ||
jeehun | 0 | 6,854,005,150 | 100% | ||
moneytron | 0 | 4,357,000,883 | 100% | ||
starrouge | 0 | 1,040,742,130 | 50% | ||
wherein | 0 | 475,939,641,974 | 100% | ||
steemfriends | 0 | 12,113,975,142 | 100% | ||
zerofive | 0 | 926,785,573 | 50% | ||
cnstm | 0 | 288,466,498,240 | 100% | ||
meins0816 | 0 | 2,706,513,072 | 75% | ||
ctime | 0 | 684,775,670,597 | 4% | ||
lianjingmedia | 0 | 1,004,005,509 | 100% | ||
cpt-sparrow | 0 | 2,724,281,196 | 100% | ||
tina3721 | 0 | 4,865,573,237 | 50% | ||
andyhsia | 0 | 8,116,282,706 | 100% | ||
minigame | 0 | 344,873,103,957 | 100% | ||
tokenindustry | 0 | 2,833,935,794 | 80% | ||
hongdangmu | 0 | 550,084,159 | 8.5% | ||
mein2070 | 0 | 2,714,777,679 | 75% | ||
cnbuddy-reward | 0 | 73,399,200,248 | 100% | ||
real3earch | 0 | 1,844,433,146 | 100% | ||
toni.pal | 0 | 0 | 0.62% | ||
hiveyoda | 0 | 6,694,827,722 | 3% | ||
logicforce | 0 | 1,925,132,343 | 50% | ||
blogstats | 0 | 1,595,099,283 | 100% |
Congratulations @june0620! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) : <table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@june0620/upvotes.png?202009090039"></td><td>You distributed more than 20000 upvotes. Your next target is to reach 21000 upvotes.</td></tr> </table> <sub>_You can view your badges on [your board](https://hivebuzz.me/@june0620) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> **Do not miss the last post from @hivebuzz:** <table><tr><td><a href="/hive-151781/@hivebuzz/meetup-uk"><img src="https://images.hive.blog/64x128/https://i.imgur.com/h6W1RRo.png"></a></td><td><a href="/hive-151781/@hivebuzz/meetup-uk">HiveBuzz supports meetups of the Hive UK Community</a></td></tr><tr><td><a href="/hivebuzz/@hivebuzz/feedback-from-the-september-1st-hive-power-up-day"><img src="https://images.hive.blog/64x128/https://i.imgur.com/zHjYI1k.jpg"></a></td><td><a href="/hivebuzz/@hivebuzz/feedback-from-the-september-1st-hive-power-up-day">Feedback from the September 1st Hive Power Up Day</a></td></tr></table>
author | hivebuzz |
---|---|
permlink | hivebuzz-notify-june0620-20200909t010632000z |
category | hive-132971 |
json_metadata | {"image":["http://hivebuzz.me/notify.t6.png"]} |
created | 2020-09-09 01:06:30 |
last_update | 2020-09-09 01:06:30 |
depth | 1 |
children | 0 |
last_payout | 2020-09-16 01:06:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,259 |
author_reputation | 370,010,458,624,423 |
root_title | "[Python #17] [Django #10] 검색 기능에 UI 추가" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 99,527,160 |
net_rshares | 0 |