G
G
Grigory Kalyashov2014-07-11 19:16:03
Django
Grigory Kalyashov, 2014-07-11 19:16:03

How to sort the list?

There is a code, views.py:

# 
coding: utf-8
from blog.models import Post
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from django.views.generic import ListView, DetailView

class PostsListView(ListView): 
    model = Post 
  
class PostDetailView(DetailView): 
    model = Post

PostsListView needs to be sorted by datetime parameter , tried model = Post.objects.order_by('-datetime') - doesn't work :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2014-07-11
@kalyashov

class PostsListView(ListView): 
    queryset = Post.objects.all().order_by('datetime')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question