Как можно улучшить такой вот код, что-то туплю. Есть идеи? Кроме кеширования.
@register.inclusion_tag('publication/last_commented.phtml')
def last_commented(request):
contenttype = ContentType.objects.get_for_model(Article)
comment_list = Comment.objects.filter(contenttype = contenttype).order_by('-id')
value_list = comment_list.values("key")
key_list = [value['key'] for value in value_list]
#object_list = Article.objects.filter(pk__in = key_list)
object_list = list()
for value in key_list:
object_list.append(Article.objects.get(pk = value))
return {'object_list': object_list, 'request': request}