Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Another option can be written in the model in the models.py file
class Post(models.Model):
#Поля модели
class Meta:
ordering = ['-pub_date',]
Try like this:
class PostListView(ListView):
model = Post
def get_queryset(self):
return super(PostListView, self).get_queryset(**kwargs).order_by('-created_at')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question