Ono To One model

dooh kim·2020년 8월 28일
0

django-model-document

목록 보기
4/7
p = Place.objects.create(address='삼성빌딩 801호')
r = Restaurant.objects.create(\
                             place=p,
                             name='심야식당',
                             rating = 5)
                             
r.place.address                             
'삼성빌팅 7,8층'

# one to one 관계는 set이 안붙는다 
# set이 안붙는다
# 이런식으로 1:1 관계에 접근가능
p.restaurant
<Restaurant: 심야식당>
profile
testify to the light

0개의 댓글