๐Ÿš€ Languege/Django-Python

[Django #2] Django ์„ค์น˜ํ•˜๊ธฐ - MAC

mini_world 2021. 1. 15. 12:52
๋ชฉ์ฐจ ์ ‘๊ธฐ

์•ˆ๋…•ํ•˜์„ธ์š” ๐Ÿ™‹‍โ™€๏ธ ๐Ÿ™‹‍โ™‚๏ธ

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” MAC OS์— Django๋ฅผ ์„ค์น˜ํ•˜๊ณ  ๊ธฐ๋ณธ ํŽ˜์ด์ง€๋ฅผ ๋„์›Œ ๋ณผ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

์ œ๊ฐ€ ํ…Œ์ŠคํŠธ ํ•˜๋Š” MAC OS ๋ฒ„์ „์€ BigSur (ver 11.1)์ž…๋‹ˆ๋‹ค :)

 

1. Xcode ์„ค์น˜ํ•˜๊ธฐ

๋”๋ณด๊ธฐ

Xcode๋Š” ์• ํ”Œ ๊ณต์‹์• ๋””ํ„ฐ๋กœ C์ปดํŒŒ์ผ๋Ÿฌ๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
Mac AppStore ์—์„œ Xcode๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค :)

 

2. Homebrew ์„ค์น˜ํ•˜๊ธฐ 

๋”๋ณด๊ธฐ

Homebrew ์„ค์น˜๋Š” ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๋Š”๊ฒŒ ์ œ์ผ ์ •ํ™•ํ•ฉ๋‹ˆ๋‹ค :)

ํ„ฐ๋„์„ ์ผœ๊ณ  ๋ช…๋ ์–ด๋ฅผ ๋ถ™์—ฌ ๋„ฃ์œผ์„ธ์š”!

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

์„ค์น˜๊ฐ€ ์™„๋ฃŒ ๋˜์—ˆ๋‹ค๋ฉด, ์„ค์น˜๊ฐ€ ์ž˜ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ฒ„์ „์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค!

brew -v

์บก์ณ ์‚ฌ์ง„์ฒ˜๋Ÿผ ๋ฒ„์ „ ์ •๋ณด๊ฐ€ ๋ณด์ธ๋‹ค๋ฉด ์ •์ƒ์ ์œผ๋กœ ์„ค์น˜ํ•œ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

3. Python 3.6 ์„ค์น˜

๋”๋ณด๊ธฐ

ํŒŒ์ด์ฌ ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€์— ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค. (https://www.python.org/downloads/)

๋‹ค์šด๋กœ๋“œ ํŽ˜์ด์ง€์—์„œ ๋‹ค์šด๋กœ๋“œ๋ฅผ ํด๋ฆญํ•˜๊ณ  ์„ค์น˜ํ•ด์ค๋‹ˆ๋‹ค!

์„ค์น˜ ๊ณผ์ •์„ ๋‹ค ๋๋‚ธ ํ›„์—๋Š” ๋ฒ„์ „ ํ™•์ธ ๋ช…๋ น์–ด๋กœ ์ž˜ ์„ค์น˜๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

python3.9 --version

์„ค์น˜๊ฐ€ ์™„๋ฃŒ ๋˜์—ˆ๋‹ค๋ฉด, ์œ„ ์บก์ณ ์‚ฌ์ง„์ฒ˜๋Ÿผ ๋ฒ„์ „์„ ํ™•์ธํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. :)

 

4. Pycharm ์„ค์น˜

๋”๋ณด๊ธฐ

ํŒŒ์ด์ฐธ์„ ์„ค์น˜ํ•˜๊ธฐ์œ„ํ•ด ๊ณต์‹ ํ™ˆํŽ˜์ด์ง€์— ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค (www.jetbrains.com/pycharm/www.jetbrains.com/pycharm/download/#section=mac)

์ปค๋ฎค๋‹ˆํ‹ฐ๋ฒ„์ „(๋ฌด๋ฃŒ)๋ฅผ ๋‹ค์šด๋กœ๋“œ ํ•˜์—ฌ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

์„ค์น˜๊ฐ€ ์™„๋ฃŒ ๋œ ํ›„๋ผ๋ฉด ์ด๋ ‡๊ฒŒ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ชฉ๋ก์—์„œ pycharm์ด ๋ณด์ž…๋‹ˆ๋‹ค.

 

 

5. Django ์„ค์น˜

๋”๋ณด๊ธฐ

     5-1) Virtualenv ์…‹์—…

๊ฐœ๋ฐœํ™˜๊ฒฝ ๋ถ„๋ฆฌ๋ฅผ ์œ„ํ•ด ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์–ด ์ค„ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.
์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ด ๊ฐ€์ƒํ™˜๊ฒฝ์—๋งŒ ์Ÿ๊ณ ๊ฐ€ ์„ค์น˜๋˜๊ธฐ๋•Œ๋ฌธ์— ๋‚˜์ค‘์— ์‚ญ์ œํ•˜๊ธฐ๋„ ํŽธํ•˜๊ณ , ๋‹ค๋ฅธ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜๊ณผ์˜ ๋ฒ„์ „ ๊ผฌ์ž„๋„ ๋ฐฉ์ง€๋ฉ๋‹ˆ๋‹ค.

virtualenv๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

 pip install virtualenv

๊ทธ๋ฆฌ๊ณ  ์ด์ œ virtualenv๋ฅผ ์‹คํ–‰ํ•  ๋””๋ ‰ํ† ๋ฆฌ (์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฃจํŠธ๋””๋ ‰ํ† ๋ฆฌ)๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

mkdir Desktop/my-Django && cd Desktop/my-Django

์ด์ œ ๊ฐ€์ƒ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์–ด์ค๋‹ˆ๋‹ค.

 virtualenv -p python3 venv

๊ฐ€์ƒํ™˜๊ฒฝ์— ์ง„์ž…ํ•ด์ค๋‹ˆ๋‹ค.  
๊ฐ€์ƒํ™˜๊ฒฝ์— ์ง„์ž…๋˜์—ˆ๋‹ค๋ฉด, ์™ผ์ชฝ์— (venv)๊ฐ€ ์ถ”๊ฐ€๋œ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

source venv/bin/activate

 

     5-2) ์žฅ๊ณ  ์„ค์น˜ ๋ฐ ์›น ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ

์žฅ๊ณ ๋ฅผ ์„ค์น˜ํ•ด์ค์‹œ๋‹ค!!

pip install django

๊ทธ๋ฆฌ๊ณ  ์žฅ๊ณ  ์›น ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

django-admin startproject mysite .

์ด์ œ ์•„๋ž˜ ๋ช…๋ น์–ด๋กœ ์žฅ๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์‹คํ–‰ํ•ด๋ด…์‹œ๋‹ค.

python manage.py runserver

์„œ๋ฒ„๊ฐ€ ์‹คํ–‰ ๋์Šต๋‹ˆ๋‹ค! 
์›น๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ผœ๊ณ  localhost:8000 ํ™•์ธํ•ด๋ด…์‹œ๋‹ค!

์‹คํ–‰ ์ž˜ ๋˜์—ˆ๋„ค์š” ^-^


Django Web Project๋ฅผ ๋งŒ๋“œ๋Š” ์ด๋ฒˆ ๋‹จ๊ณ„๊นŒ์ง€ ๋งˆ๋ฌด๋ฆฌ ํ–ˆ๋‹ค๋ฉด ๋””๋ ‰ํ† ๋ฆฌ๋Š” ์ด๋ ‡๊ฒŒ ๊ตฌ์„ฑ๋˜์—ˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. 

์ด์ œ ๋‹ค์Œ ๋‹จ๊ณ„๋กœ ๋„˜์–ด๊ฐ€์„œ ์ด๊ฒƒ์ €๊ฒƒ ๋งŒ๋“ค์–ด ๋ด…์‹œ๋‹ค!!!

728x90