바뀜
둘러보기로 가기
검색하러 가기
→메타클래스
27번째 줄:
27번째 줄:
+
)
)
</syntaxhighlight>[공식 메뉴얼에선 unique_together 안에 튜플이 아니라, 리스트로 하는데.. 둘다 가능한지 확인이 필요해보인다.
</syntaxhighlight>[공식 메뉴얼에선 unique_together 안에 튜플이 아니라, 리스트로 하는데.. 둘다 가능한지 확인이 필요해보인다.
+
+=== ordering ===
+모델 자체를 어떤 방식으로 정렬할지 지정한다.<syntaxhighlight lang="python">
+class 모델명
+ ...
+ created_at = models.DateTimeField(auto_now_add=True)
+ ...
+ class Meta:
+ ordering = ['-created_at'] #created_at 속성의 역순으로 정렬한다는 의미.
+</syntaxhighlight>