Django group object by the first character of a column

前端 未结 3 726
甜味超标
甜味超标 2021-02-15 15:42

I\'m trying to group records by the character of name field of each record and limit the items in each group, here is what I have came up with:

desi         


        
3条回答
  •  Happy的楠姐
    2021-02-15 16:19

    For Django REST you can refer,

    Get Response Group by Alphabet

    Response

    {
        "A": [
            "Adelanto",
            "Azusa",
            "Alameda",
            "Albany",
            "Alhambra",
            "Anaheim"
        ],
        "B": [
            "Belmont",
            "Berkeley",
            "Beverly Hills",
            "Big Sur",
            "Burbank"
        ],
        ......
    
    }
    

提交回复
热议问题