Specifically, I have a model that has a field like this
pub_date = models.DateField('date published')
I want to be able to easily grab the object with the most recent pub_date. What is the easiest/best way to do this?
Would something like the following do what I want?
Edition.objects.order_by('pub_date')[:-1]
You can also simplify things by putting
get_latest_byin the model’s Meta, then you’ll be able to doSee the docs for more info. You’ll probably also want to set the
orderingMeta option.