모델에 메타데이터를 제공하기 위해 사용된다.<syntaxhighlight lang="python">
모델에 메타데이터를 제공하기 위해 사용된다.<syntaxhighlight lang="python">
class 모델명(models.Model):
class 모델명(models.Model):
38번째 줄:
39번째 줄:
ordering = ['-created_at'] #created_at 속성의 역순으로 정렬한다는 의미.
ordering = ['-created_at'] #created_at 속성의 역순으로 정렬한다는 의미.
</syntaxhighlight>
</syntaxhighlight>
+
+
= 모델 안에서 정의하는 함수 =
+
모델 클래스 안에 함수를 정의할 수 있다. 객체.함수() 형태로 뷰에서 사용할 수 있고, <nowiki>{{객체.함수}}</nowiki> 형태로 탬플릿에서 사용할 수도 있다..! 이런 기능이 있다면 엄청나게 많은, 간단한 활용이 가능해지지. url.py를 거치지 않고도 하위객체를 생성한다든가.