Almost - the `get_latest_by` attribute goes in the inner Meta class.
class Event(models.Model):
...
class Meta:
get_latest_by = 'date'
Also note you have to quote the name of the field.
--
DR.
On 25 May 2011 16:41, Gchorn <[email protected]> wrote:
> Thank you Daniel! This is really very helpful. I had started working
> on a somewhat convoluted workaround, but was still running into some
> problems with that, so I'm glad to hear there's a relatively simple
> way of getting this done.
>
> However, I'm somewhat unclear on the specific details of how to do
> some of what you outlined below. Since the '.last' method is a built-
> in queryset function, can I just add a line to my Event class
> definition in the models.py file like so?
>
> class Event(models.Model):
> product = models.ForeignKey(Product)
> date = models.DateField('Event Date')
> get_latest_by = date
>
> Sorry I'm still a little new to Python as well, and learned about
> defining classes not long before jumping into Django. Thanks again
> for your help!
>
> cheers,
> Guillaume
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.