On Aug 13, 11:18 am, Steven Davidson
wrote:
> > It would have to be another datetime field rather than an is_current flag
> > because an is_current flag wouldn't help me for queries in the past (if that
> > makes sense).
>
> Ah yes, of course, I had not fully grasped that bit. A nullable foreign
>
> It would have to be another datetime field rather than an is_current flag
> because an is_current flag wouldn't help me for queries in the past (if that
> makes sense).
Ah yes, of course, I had not fully grasped that bit. A nullable foreign key
reference to the State that supersedes it might
On Aug 13, 9:51 am, Steven Davidson
wrote:
> Hmm, I can't fathom it.
>
> I would opt for a single simple query that returns a little more than you
> need and post-process it in python. This would be more maintainable than a
> hairy ORM query, I'd say; but if you have vast numbers of results that
Hmm, I can't fathom it.
I would opt for a single simple query that returns a little more than you
need and post-process it in python. This would be more maintainable than a
hairy ORM query, I'd say; but if you have vast numbers of results that may
not be appropriate.
Alternatively, and presuming
On Aug 12, 8:26 pm, Alec Shaner wrote:
> Hopefully some django sql guru will give you a better answer, but I'll take
> a stab at it.
>
> What you describe does sound pretty tricky. Is this something that has to be
> done in a single query statement?
It doesn't have to be, but I would like to try
I see. What about Alec Shaner's suggestion? If you replace 'order_by' with
'latest' it will be similar to my suggestion with just two queries.
- Paulo
On Fri, Aug 13, 2010 at 8:28 AM, Emily Rodgers wrote:
> On Aug 12, 10:00 pm, Paulo Almeida
> wrote:
> > Can you sequentially add the states for
On Aug 12, 10:00 pm, Paulo Almeida
wrote:
> Can you sequentially add the states for each foo? I'm thinking of something
> like:
>
> states = []
> for foo in foos:
> foo_state = State.objects.filter(foo=foo, first_dt__lte=dt,
> last_dt__gte=dt)
> if foo_state:
> states.append(foo_st
Can you sequentially add the states for each foo? I'm thinking of something
like:
states = []
for foo in foos:
foo_state = State.objects.filter(foo=foo, first_dt__lte=dt,
last_dt__gte=dt)
if foo_state:
states.append(foo_state)
else:
states = State.objects.filter(foo=foo
Hopefully some django sql guru will give you a better answer, but I'll take
a stab at it.
What you describe does sound pretty tricky. Is this something that has to be
done in a single query statement? If you just need to build a list of
objects you could do it in steps, e.g.:
# Get all State obje
Hi,
I am a bit stuck on this and can't seem to figure out what to do.
I have a model that (stripped down for this question) looks a bit like
this:
class State(models.Model):
first_dt = models.DateTimeField(null=True)
last_dt = models.DateTimeField(null=True)
foo = models.CharField(Fo
10 matches
Mail list logo