Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db_posts = Post.objects.values('id')\
- .filter(status='public')\
- .order_by('-date_create')
- id_list = [post['id'] for post in db_posts]
- posts = []
- for id in id_list:
- post = Post.objects.get(id=id)
- post_comments = Comment.objects.filter(post=id).count()
- posts.append({
- 'id': post.id,
- 'title': post.title,
- 'intro_text': post.intro_text,
- 'main_text': post.main_text,
- 'cut': post.cut,
- 'date_create': post.date_create,
- 'date_update': post.date_update,
- 'status': post.status,
- 'tags': post.get_tags(),
- 'comments': post_comments,
- })
Add Comment
Please, Sign In to add comment