2
我的模式是:如何通过GenericForeignKey订购?
class Subscription(models.Model):
user = models.ForeignKey(User, related_name='subscription', editable=False)
following_content_type = models.ForeignKey(ContentType, editable=False)
following_id = models.PositiveIntegerField(editable=False)
following = generic.GenericForeignKey('following_content_type', 'following_id')
created_at = models.DateTimeField(auto_now_add=True, editable=False)
email_notification = models.BooleanField(default=False)
class Meta:
ordering = ["-following__created_at"]
这种排序不能正常工作。基于GenericForeignKey设置默认排序的正确方法是什么?