Reputation: 539
Here is my code:
def get_queryset(self):
return Post.objects.filter(published_date__lte=timezone.now().order_by('-published_date'))
I want to list the post with an order here. However when I run the server, I am getting error like this:
'datetime.datetime' object has no attribute 'order_by'
I am watching some udemy course so I am doing whatever he do. Can someone help me about it?
Upvotes: 0
Views: 88
Reputation: 2342
You are missing a closing parenthesis )
after timezone.now()
. Add a closing parenthesis and it will be resolved.
return Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')
Upvotes: 4