Hi I want to do this in my views:
recent_articles_list = Article.objects.order_by('-timestamp')[:3]
headline_article = recent_articles_list.pop()[0]
however, just get the error:
'QuerySet' object has no attribute 'pop'
I have also transformed it to a list:
headline_article = list(recent_articles_list).pop[0]
But then I get:
'builtin_function_or_method' object is not subscriptable
Any suggestions would be much appreciated!
If you want to use it in template, i suggest to use
{{forloop.first}}Pass the
recent_articles_listQuerySet to the template, and:https://docs.djangoproject.com/en/1.3/ref/templates/builtins/?from=olddocs#for