๐Ÿšฆ ์žฅ๊ณ  ORM ์ดํ•ดํ•˜๊ธฐ

may_soouuยท2020๋…„ 9์›” 28์ผ
0

Django-ORM

๋ชฉ๋ก ๋ณด๊ธฐ
1/5
post-thumbnail

์ฟผ๋ฆฌ์…‹ ์ดํ•ดํ•˜๊ธฐ

1. ํ•„์š”ํ•œ ์—ด๋งŒ ๊ณจ๋ผ ์กฐํšŒํ•˜๊ธฐ

2๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ๋‹ค.
1 ) ์ฟผ๋ฆฌ์…‹์˜ values ์™€ values_list
2 ) only ๋ฉ”์†Œ๋“œ

ex. first_name ์นผ๋Ÿผ๊ณผ last_name ์นผ๋Ÿผ์—์„œ ์ด๋ฆ„์ด R๋กœ ์‹œ์ž‘ํ•˜๋Š” ์—ด ์ฐพ๊ธฐ

User.objects.filter(
    first_name__startswith='R'
).values('first_name', 'last_name')

๊ณ„์† ์ถ”๊ฐ€์ค‘ == ===========

profile
back-end ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€