model 내용

dooh kim·2020년 8월 28일
0

django-model-document

목록 보기
5/7

다른 app.model 참조하기

# 다른 모델 참조
instagram_user = models.ForeignKey(InstagramUser)
# 문자열로 app_name.model_name
instagram_user = models.ForeignKey('many_to_many.InstagramUser')

다른 database에서 dump 해서 가져왔을 때
db 컬럼명이 django 에서는 사용하지 못하는 '_ _ ' underscore 두개 사용하는 경우 필드 옵션으로

db_column=category__name

python 에서는 name이라고 쓰지만
작동하는 db column은 category__name 으로 바꿀 수 있다

Meta options

class Meta:
    ordering = ['horn_length']
    verbose_name_plural = "stories"
profile
testify to the light

0개의 댓글