I am creating a popular page for my app and for the most part this is just
to gain an understanding.
The idea is to divide the number of views by the days old, now i don't know
if this will be successful or even working but like I said its go get an
idea of how queries work...
My fields are named: views and created. Below is an idea of what I'm
thinking of.
(now - created) / views
For my view I have:
def popular(request):
popular_posts = Post.objects.all().order_by('-id')[:50]
return render_to_response(
'posts/popular.html',
{'popular_posts': popular_posts},
)
Obviously that just gets all the objects ordered by id. Is there a way to
achieve something similar to what I'm looking for without going into loads
of complex code?
Any ideas? I know its something to do with query expressions and looking at
this
page<https://docs.djangoproject.com/en/1.4/topics/db/queries/#query-expressions>
confuses
the hell out of me. Any guidelines, or is this even achievable?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/gWzK1UJfkfIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.