๋ณธ ํ๋ก์ ํธ๋ ํจ์บ ๊ฐ์๋ฅผ ์ฐธ๊ณ ํฉ๋๋ค.
<์ด์ ๊ธ>
https://silvercoding.tistory.com/14
[DJANGO ๊ธฐ์ด] 4. ํ์๊ฐ์ ํ์ด์ง ๋ง๋ค๊ธฐ (MTV ๊ตฌ์กฐ - T, V ์์ฑ)
๋ณธ ํ๋ก์ ํธ๋ ํจ์บ ๊ฐ์๋ฅผ ์ฐธ๊ณ ํฉ๋๋ค. <์ด์ ๊ธ> https://silvercoding.tistory.com/13 https://silvercoding.tistory.com/12 https://silvercoding.tistory.com/11 [DJANGO ๊ธฐ์ด] ๊ฐ์ํ๊ฒฝ ์ค์ ๋ฐ ์ฑ ์์ฑ..
silvercoding.tistory.com
CDN
๋ถํธ์คํธ๋ฉ CDN์ Content Delivery Network์ ์ฝ์๋ก, ์ธ๋ถ์ ์๋ CSS๋๋ Javascript์ฃผ์๋ฅผ ๊ฐ์ ธ์ฌ ์ ์๋๋ก ํด์ฃผ๋ ์๋น์ค์ด๋ค.
๊ฐ๋ตํ ๊ฐ๋ ์ ๋ณด๊ณ ๋์ด๊ฐ๋๋ก ํ์. CSS๋ Javascript์ ๊ฐ์ ํ์ผ์ด ์๋ณธ ์๋ฒ์ ๋ค์ด๊ฐ์๊ณ ์ฌ๋ฌ๊ฐ์ ์๋ฒ๋ก ๋ถ์ฐ๋์ด ์๋ ๊ฒ์ด๋ค. ๋ง์ฝ ์ฐ๋ฆฌ๋๋ผ์์ ๊ธ๋ก๋ฒ ์๋น์ค๋ฅผ ํ๊ฒ ๋๋ฉด ์๋ฒ๊ฐ ํ๊ตญ์ ์๊ฒ ๋๊ณ , ๊ทธ๋ผ ์๋ณธ์ด ํ๊ตญ์ ์๊ฒ ๋๋ค. ๊ทธ๋ ๊ฒ ๋๋ฉด ๋ฏธ๊ตญ์ ์๋ ์ฌ์ฉ์๋ ๋ฉ๋ฆฌ ์๋ ์๋ฒ ํ์ ๋๋ฆฐ ์๋น์ค๋ฅผ ์ ๊ณต๋ฐ๊ฒ ๋๋ค. ๊ทธ๋์ ์ค๊ฐ์ ์ฌ๋ฌ ์๋ฒ๋ค์ ๋๋ ๊ฒ์ด๋ค. ๋๋ผ๋ณ๋ก ์๋ฒ๋ฅผ ๋ฟ๋ ค๋๋ ๊ฒ์ด๋ค. ์ด์ฒ๋ผ ์์ ์๊ฒ ๋น ๋ฅธ ๊ณณ์ผ๋ก ์ ์ํด์ ๋ฐ์๊ฐ๋ ์๋น์ค๊ฐ CDN ์ด๋ค.
๋ณธ ํ๋ก์ ํธ์์ ์ฐ์ธ CSS ๋งํฌ๋ ์๋ณธ์ ์๋ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์จ ๊ฒ ์๋๋ผ ํ์ฌ pc์์ ๊ฐ์ฅ ๋น ๋ฅธ ์๋ฒ์์ ๊ฐ์ ธ์จ ๊ฒ์ด๋ค.
(๋ ์์ธํ ์์๋ณด๋ ค๋ฉด)
CDN ์ฐธ๊ณ ๋ฌธ์
https://docs.microsoft.com/ko-kr/azure/cdn/cdn-overview
CDN(์ฝํ ์ธ ๋ฐฐ๋ฌ ๋คํธ์ํฌ)์ด๋? - Azure
Azure CDN(Content Delivery Network) ๋ฌด์์ธ์ง ์์๋ณด๊ณ ๊ณ ๋์ญํญ ์ฝํ ์ธ ๋ฅผ ๋ฐฐ๋ฌํ๋ ๋ฐฉ๋ฒ์ ์์๋ด ๋๋ค.
docs.microsoft.com
๊ธฐ์กด์ ์ด๋ฌํ CDN์ ์ฌ์ฉํ์ฌ CSS๋ฅผ ์ฌ์ฉํ์๋ค. ์ด๋ฒ ๊ธ์์๋ CDN์ ์ฐ์ง ์์ผ๋ฉด์ CSS๋ฅผ ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ ์์๋ณผ ๊ฒ์ด๋ค.
์ง์ ๋ง๋ CSS ํ์ผ์ ์ ์ฉํ๋ ค๋ฉด
1. static ํด๋ ๋ง๋ค๊ธฐ
community ---> static ํด๋ ์์ฑ
์์ฑํ static ํด๋์์ css, javascript ํ์ผ ๊ด๋ฆฌ๋ฅผ ํ๊ฒ๋๋ค.
settings.py
...
import os
...
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
...
์ด๋ฏธ STATIC_URL ์์ฑ๋์ด์๋ค. ์ด์ cssํ์ผ์ ์ ๊ทผํ์ ๋ ๊ทธ๊ฒ ์ด๋ํ์ผ์ ์๋์ง๋ฅผ ์๋ ค์ฃผ์ด์ผ ํ๋ค.
STATICFILES_DIRS = [] ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค์ด ํด๋๋ฅผ ๋ฃ์ด์ฃผ๋ฉด ๋๋ค. BASE_DIR ๋ ํ๋ก์ ํธ ํด๋์ธ community์ด๊ณ , ์์ฑํ static ํด๋์ joinํด์ค๋ค. os๋ฅผ importํ๋ ๊ฒ๋ ์์ง ๋ง์.
2. CSS ํ์ผ ์ค๋น
๋ฐฑ์๋ ์ค์ฌ์ ํ๋ก์ ํธ์ด๋ฏ๋ก ์ง์ CSS ํ์ผ์ ๋ง๋ค์ง ์๊ณ ๋ถํธ์คํธ๋ฉ์ ํ ๋ง๋ฅผ ์ฌ์ฉํ ๊ฒ์ด๋ค.
<bootstrap 4.3 themes free>
Bootswatch: Free themes for Bootstrap
Customizable Changes are contained in just two SASS files, enabling further customization and ensuring forward compatibility.
bootswatch.com
์ด๊ณณ์์ ๋ง์์ ๋๋ ํ ๋ง๋ฅผ ๊ณจ๋ผ์
bootstrap.min.css ๋ฅผ ๋ค์ด๋ฐ์์ค๋ค.
๋ค์ด๋ฐ์ ํ์ผ์ staticํด๋์ ์ฎ๊ฒจ์ค๋ค.
์ด์ ๋ชจ๋ ์ค๋น๋ฅผ ๋ง์ณค๊ณ , html์ ์ ์ฉํด์ค ๋ค์ ๊ฒฐ๊ณผ ํ์ธ์ ํด๋ณธ๋ค.
3. html์ CSS ์ ์ฉํด์ฃผ๊ธฐ
user ---> templates ---> register.html
์๋ ์ฝ๋
...
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js" integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script>
</head>
...
CSS ํ ๋ง ์ ์ฉ ์ฝ๋
...
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/bootstrap.min.css" />
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js" integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script>
</head>
...
link ํ๊ทธ๋ง ๋ฐ๊พผ๋ค. static ํด๋์ css ํ์ผ์ ์ฐ๊ฒฐ ํด์ฃผ๋ฉด ๋๋ค.
๋ชจ๋ ๋ง์น ํ ์๋ฒ์ ๋ค์ด๊ฐ๋ณด๋ฉด ์ด๋ ๊ฒ ํ๋ คํ ํ ๋ง๊ฐ ์ ์ฉ์ด ๋ ๊ฒ์ ๋ณผ ์ ์๋ค!
๋ค์ ๊ธ์์๋ ์ธ์ ๋ฐ ๋ก๊ทธ์ธ์ ์์ ๋ณด๋๋ก ํ๋ค.
'์น > Django' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[DJANGO ๊ธฐ์ด] 7. Template ํ์ฅ, ์์ (0) | 2021.06.19 |
---|---|
[DJANGO ๊ธฐ์ด] 6. ์ธ์ , ๋ก๊ทธ์ธ ํ์ด์ง ๊ตฌํ (0) | 2021.06.19 |
[DJANGO ๊ธฐ์ด] 4. ํ์๊ฐ์ ํ์ด์ง ๋ง๋ค๊ธฐ (MTV ๊ตฌ์กฐ - T, V ์์ฑ) (0) | 2021.06.16 |
[DJANGO ๊ธฐ์ด] 3. Django admin, ๊ฐ๋ฐ ์๋ฒ ํ์ฉ (0) | 2021.06.14 |
[DJANGO ๊ธฐ์ด] 2. MTV์ Model ์์ฑ, sqlite db ๊ธฐ๋ณธ์ ์ธ ๊ด๋ฆฌ (0) | 2021.06.14 |