[Django] Models

HyunDong Lee·2021년 2월 3일
0

Django

목록 보기
5/6
post-thumbnail
  • models

    • models in python are a class which represent a table in a database
    • 파이썬에서 모델은 데이터베이스의 테이블을 나타내는 클래스이다.
    • each type of data we have (e.g articles, users) is represented by it's own model
    • 우리가 가진 article, users 각각의 종류의 데이터는 그 자체의 모델에 의해서 나타내진다.
    • each model maps to a single table in a database
    • 각각의 모델을 데이터 베이스안에 하나의 테이블에 연결시켜준다.
    • 예를 들어서 author, articles, user app이 3개 있다면 각각 author, articles, user 3개의 table이 존재한다.
  • 데이터 베이스 내용

    • class article():
      • title = models.charField()
      • body = models.TextField()
    • In the database
      • 테이블이 생성 된다.

models.py

  • 안에 different field를 각각 만들어준다. 약간 db에서 query문 생성하는 것처럼 작동한다.
  • 이미지, 텍스트, date 여러 field타입이 있는데 각각 다르다.
  • django docs reference

Models | Django documentation | Django

0개의 댓글