Ah, very good. I understand now. Thank you both for your help.
On Friday, October 19, 2018 at 10:49:28 PM UTC-5, Daniel Veazey wrote:
>
> I'm using 2.1. I have a list of blog posts, and I want to display them
> differently based on their age. The most recent post will be displayed
>
yes Joel is right you hit 3 time de DB is not good for optimization create
a variable and save the one query
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
POSTS = Post.objects.all().order_by('-date_posted')
context['latest'] = POSTS[0]
You're using three different database queries. You could just fetch the
most recent 11 objects, into a variable, use [0] for the most recent one.
And then display the next 10 and break them into columns with css wrap.
On Sat, 20 Oct, 2018, 9:20 AM Daniel Veazey, wrote:
> I'm using 2.1. I have
If it helps, my template looks like this:
{% extends "photomanager/base.html" %}
{% block content %}
{% if latest.photo %}
Photographer: {{ latest.photo.photographer }}
Caption: {{ latest.photo.caption }}
{% endif %}
{{ latest.title }}
{{
I'm using 2.1. I have a list of blog posts, and I want to display them
differently based on their age. The most recent post will be displayed
prominently, and the 10 most recent posts after that will be displayed in
two columns below it. The way I'm passing the view to the template is:
class
5 matches
Mail list logo