官术网_书友最值得收藏!

  • Django 2 by Example
  • Antonio Melé
  • 47字
  • 2021-06-25 21:19:01

Using order_by()

You can order results by different fields using the order_by() method of the manager. For example, you can retrieve all objects ordered by their title, as follows:

Post.objects.order_by('title')

Ascending order is implied. You can indicate descending order with a negative sign prefix, like this:

Post.objects.order_by('-title')
主站蜘蛛池模板: 麻栗坡县| 嵊州市| 于田县| 宁国市| 石台县| 普陀区| 前郭尔| 绥德县| 古丈县| 重庆市| 和平县| 马鞍山市| 郎溪县| 河曲县| 南充市| 永城市| 塔城市| 丽江市| 湖州市| 西城区| 崇信县| 迁安市| 安多县| 辽源市| 双桥区| 龙胜| 莱西市| 金塔县| 明溪县| 迭部县| 浙江省| 渭南市| 玉龙| 阜新市| 宁波市| 龙口市| 容城县| 阜宁县| 大英县| 丹棱县| 宜宾县|