๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
โœ’๏ธ Python Programming/Frameworks

< django - 10 >

by A Lim Han 2022. 8. 4.

10. ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ์„ค์น˜ ๋ฐ ์ ์šฉ

 

 

 

# ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ์„ค์น˜ ๋ฐ ์งˆ๋ฌธ ๋ชฉ๋ก์—์˜ ์ ์šฉ

1. ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ์„ค์น˜ -> projects\mysite\templates\pybo\question_list.html ํŒŒ์ผ์— ์•„๋ž˜์ฒ˜๋Ÿผ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ์ ์šฉ

+ ์ฝ”๋“œ์˜ ๋งจ ์œ„์— {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'bootstrap.min.css' %}"> ์ถ”๊ฐ€ํ•จ

 

 

 

2. ํ…œํ”Œ๋ฆฟ์ด ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์•„๋ž˜์ฒ˜๋Ÿผ projects\mysite\templates\pybo\question_list.html ํŒŒ์ผ์„ ์ˆ˜์ •

Line 3 ~ ๋๊นŒ์ง€ ๋‹ค ์ˆ˜์ •

+ <ul> ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์งˆ๋ฌธ ๋ชฉ๋ก์„ ํ…Œ์ด๋ธ” ๊ตฌ์กฐ๋กœ ๋ณ€๊ฒฝ

 

+ ์ž‘์„ฑ์ผ์‹œ ํ•ญ๋ชฉ๊ณผ ๋ฒˆํ˜ธ ์ถ”๊ฐ€ (Line 7 ~ 9)

+ Line 16์˜ {{ forloop.counter }}๋Š” for ๋ฌธ์˜ ํ˜„์žฌ ์ˆœ์„œ๋ฅผ ์˜๋ฏธ

 

+ class="container my-3"class="table"class="table-dark" ๋“ฑ์€ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ์Šคํƒ€์ผ์— ์ •์˜๋˜์–ด ์žˆ๋Š” ํด๋ž˜์Šค์ž„

(Line 3, 4, 6)

 

 

 

3. http://localhost:8000/pybo/ ํŽ˜์ด์ง€๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์ด ์งˆ๋ฌธ ๋ชฉ๋ก์— ์ ์šฉ๋จ์„ ํ™•์ธ

 

 

 

 

# ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์˜ ์งˆ๋ฌธ ์ƒ์„ธ ํ…œํ”Œ๋ฆฟ์—์˜ ์ ์šฉ

1. projects\mysite\templates\pybo\question_detail.html ํŒŒ์ผ์„ ์•„๋ž˜์™€ ๊ฐ™์ด ์ˆ˜์ •

+ ์งˆ๋ฌธ, ๋‹ต๋ณ€์— ๊ด€ํ•œ ์‚ฌํ•ญ์€ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์˜ card ์ปดํฌ๋„ŒํŠธ ์‚ฌ์šฉ

+ ์งˆ๋ฌธ๊ณผ ๋‹ต๋ณ€ ๋‚ด์šฉ์—๋Š” style="white-space: pre-line;" ๊ณผ ๊ฐ™์€ ๊ธ€ ๋‚ด์šฉ์˜ ์ค„ ๋ฐ”๊ฟˆ์„ ์ •์ƒ์ ์œผ๋กœ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•œ ์Šคํƒ€์ผ ์ง€์ • (Line 8, 21)

 

+ ์‚ฌ์šฉํ•œ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํด๋ž˜์Šค

๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํด๋ž˜์Šค ์˜๋ฏธ
card
card-body
card-text
๋ถ€ํŠธ์ŠคํŠธ๋žฉ Card ์ปดํฌ๋„ŒํŠธ
badge ๋ถ€ํŠธ์ŠคํŠธ๋žฉ Badge ์ปดํฌ๋„ŒํŠธ
form-control
form-label
๋ถ€ํŠธ์ŠคํŠธ๋žฉ Form ์ปดํฌ๋„ŒํŠธ
border-bottom ๋ถ€ํŠธ์ŠคํŠธ๋žฉ Form ์ปดํฌ๋„ŒํŠธ
my-3 ์ƒํ•˜ ๋งˆ์ง„๊ฐ’ =  3
py-2 ์ƒํ•˜ ํŒจ๋”ฉ๊ฐ’ = 2
p-2 ์ƒํ•˜์ขŒ์šฐ ํŒจ๋”ฉ๊ฐ’ = 2
d-flex justify-content-end ์ปดํฌ๋„ŒํŠธ์˜ ์šฐ์ธก ์ •๋ ฌ
bg-light ์—ฐํšŒ์ƒ‰ ๋ฐฐ๊ฒฝ
text-dark ๊ธ€์ž ์ƒ‰์„ ๊ฒ€์ •์œผ๋กœ
text-start ์ขŒ์ธก ์ •๋ ฌ
btn btn-primary ๋ถ€ํŠธ์ŠคํŠธ๋žฉ ๋ฒ„ํŠผ ์ปดํฌ๋„ŒํŠธ

 

 

 

2. http://localhost:8000/pybo/3/ ํŽ˜์ด์ง€๋ฅผ ์š”์ฒญํ•˜์—ฌ ์งˆ๋ฌธ ์ƒ์„ธ ํ™”๋ฉด์— ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์ด ์ ์šฉ๋จ์„ ํ™•์ธ

 

 

 

 

'โœ’๏ธ Python Programming > Frameworks' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

< django - 12 >  (0) 2022.08.05
< django - 11 >  (0) 2022.08.04
< django - 9 >  (0) 2022.08.03
< django - 8 >  (0) 2022.08.01
< django - 7 >  (0) 2022.08.01