我有这样的模型
class Category(models.Model):
title = models.CharField(max_length=100, db_index=True)
slug = models.SlugField(max_length=100, db_index=True)
def __str__(self):
return "%s"%self.title
class Video(models.Model):
title = models.CharField(max_length=100, unique=True)
slug = models.SlugField(max_length=100, unique=True)
idlink = models.CharField(max_length=50)
posted = models.DateField(db_index=True, auto_now_add=True)
category = models.ForeignKey(Category)
def __str__(self):
return "%s"%self.title
我的views.py是
def list_video_cat(request, slug):
video = Video.objects.filter(category__slug=slug).order_by('-posted')
return render(request, 'category.html', {'videos':video})
我想把我的帖子显示为旧的,但似乎在这种情况下不起作用。我该怎么办?
P / S"重复帖子"没有解决我的问题