Queryset API distinct() does not work?

后端 未结 2 1753
执念已碎
执念已碎 2021-01-05 12:52
class Message(models.Model):
    subject = models.CharField(max_length=100)
    pub_date = models.DateTimeField(default=datetime.now())

class Topic(models.Model):
          


        
2条回答
  •  渐次进展
    2021-01-05 13:25

    You'll find the explanation in the documentation for .distinct().

    I would de-normalize by adding a modified_date field to the Topic model and updating it whenever a Message is saved or deleted.

提交回复
热议问题