> This sounds like what django-reversion[1] does :)
>
> [1]:http://github.com/etianen/django-reversion#readme

We have to cover the situation where some clients might still have
rev(n-1), while some are up-to-date with rev(n). So we _probably_ need
the history in the same table as the current version.

I'm aware this is borderline "big requirements up front", but the
answer turns out to be...

class ThingManager(models.Manager):

    def get_query_set(self):
        qs = super(ThingManager, self).get_query_set()
        max_pids = QuerySet(self.model, using=self._db)
        max_pids =
max_pids.values('name').annotate(Max('pid')).values('pid')
        return qs.filter(pid__in=max_pids)

Now we can write any ORM statement we can think of, and (if those
lines continue to pass tests) then we only see the top horizon of the
data. Unless we need to go deeper.

Thanks, all!

--
  Phlip

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to