Group by Foreign Key and show related items - Django

前端 未结 2 1327
离开以前
离开以前 2020-12-28 18:33

I have the following models:

class Company(CachedModel):
    name = models.CharField(max_length=255)

class UserExtendedProfile(CachedModel):

    company =          


        
2条回答
  •  臣服心动
    2020-12-28 18:46

    If you are simply trying to accomplish this for display purposes, take a look at: https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#regroup

    It lets you do just that inside the template.

提交回复
热议问题