I agree it's a bit devious, it took me a couple of minutes to figure out it
would work for this particular use case.
Ideally there would a kwarg to Prefect that does the limiting
automatically, something like:
SELECT train.id, s.* FROM train LATERAL JOIN (
SELECT * FROM seat WHERE seat.trai
Thanks Simon! That worked.
I would say it's a bit devious though, and it was nice if there was a
method that didn't use `distinct`, which has its own issues. (And can't be
used for any number of items other than 1 in this case.)
On Tue, Mar 3, 2015 at 7:15 AM, Simon Charette wrote:
> Can your s
Can your seats be part of multiple trains?
Is there a reason you defined a ManyToMany from Train to Seat instead of a
ForeignKey from Seat to Train?
If your schema was defined as the latter the following could probably work
(given you only want the first Seat of each Train object):
trains =
T
Hi,
Say that I have a model Train and it has a ManyToMany to model Seat. I'm
looking at a queryset of Train and I want to do a prefetch_related on it,
but I don't want to get all the Seat objects; I want only the first Seat
object for each Train object. Is this possible with prefetch_related
4 matches
Mail list logo