๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ป Deep Wide Programming/Django

[โ›บ๏ธํด๋ก ์ฝ”๋”ฉ] django Creating the Apps/ Models

728x90
๋ฐ˜์‘ํ˜•

django Creating the Apps

 

(๋ฒ„๋ธ” ์•ˆ์—์„œ)

django-admin startapp ์•ฑ์ด๋ฆ„

 

django-admin startapp rooms๋ฅผ ์ž…๋ ฅํ–ˆ๋”๋‹ˆ, rooms๋ผ๋Š” ํด๋”๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ๋Š”๋ฐ ์•ˆ์— ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์ค€๋น„๋ฌผ๋“ค์ด ์ด๋ฏธ ์ฑ™๊ฒจ์ ธ ์žˆ๋‹ค.

(์ด๋•Œ ์ƒ์„ฑ๋œ ํŒŒ์ผ ๋ช…๋“ค์„ ์ž„์˜๋กœ ๋ฐ”๊พธ๋ฉด ์•ˆ๋œ๋‹ค. library๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ, framework๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ!!

โ—๏ธframework = ์ •ํ•ด์ง„ ๋ฃฐ๋Œ€๋กœ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. 

โ—๏ธlibrary = ๋ญ”๊ฐ€๋ฅผ ์ง“๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค. ex. react )

 

 

 

 

๊ณ„ํšํ•œ ์žฅ๊ณ  app์— ํ•„์š”ํ•œ ํ•˜์œ„ app ํด๋”๋“ค์„ ์ƒ์„ฑํ•ด์ค€๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๊ฐ๊ฐ์˜ ํด๋”์— urls.py ํŒŒ์ผ์„ ์ƒ์„ฑํ•ด์ค€๋‹ค. ์‚ฌ์šฉํ•˜๊ฒŒ๋  url์ด ๊ต‰์žฅํžˆ ๋งŽ์„ ๊ฑฐ๊ธฐ ๋•Œ๋ฌธ์—, configํด๋”์˜ url ํŒŒ์ผ์—์„œ๊ฐ€ ์•„๋‹ˆ๋ผ, ๊ฐ๊ฐ์˜  appํด๋”์—์„œ ๊ด€๋ฆฌํ•ด์ฃผ๋Š” ๊ฑฐ๋‹ค. 

 

(์•„์ง ์ด ์ƒํƒœ๋กœ๋Š” ์žฅ๊ณ  ์„œ๋ฒ„์—์„œ ๋ˆˆ์— ๋ณด์ด๋Š” ๋ณ€ํ™”๋Š” ์—†๋‹ค. ๋‚˜์ค‘์— ํ•„์š”ํ•œ๊ฑฐ ๋„ฃ์–ด์ค€ ๋‹ค์Œ์— ์œ„ applications์„ config ํ•˜์œ„์˜ settings.py์—  ์„ค์น˜ํ•ด์ค˜์•ผ ํ•œ๋‹ค. )

 

 

Model = ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณด์—ฌ์ง€๋Š” ๋ชจ์Šต

(model.py ์—์„œ ์“ฐ์ด๋Š” ํŒŒ์ด์ฌ ๊ธฐ๋ณธ ๋ฌธ๋ฒ• ์ฐธ๊ณ : 

github.com/yekyung2/Practice_Python/blob/master/Python%20class%20study.ipynb

 

 

 

์ถœ์ฒ˜: docs.djangoproject.com/en/2.2/topics/auth/customizing/

 

 

๐Ÿ“ŒDependency on app with no migrations : users ์˜ค๋ฅ˜ ํ•ด๊ฒฐํ•˜๊ธฐ

์„œ๋ฒ„๋ฅผ ์ข…๋ฃŒํ•˜๊ฑฐ๋‚˜/ ์ƒˆ๋กœ์šด ํ„ฐ๋ฏธ๋„์„ ์ƒ์„ฑํ•œ๋‹ค.

 

python manage.py makemigrations

python manage.py migrate

 

728x90
๋ฐ˜์‘ํ˜•