On Thursday, 12 April 2012 at 10:47 PM, Andre Terra wrote:
> On Thu, Apr 12, 2012 at 10:01 AM, David (mailto:cthl...@gmail.com)> wrote:
> > Log.objects.distinct('thing__id').order_by('thing__id',
> > '-modified_on').select_related().filter(thing__deleted=0)[:20]
> >
> >
On Thu, Apr 12, 2012 at 10:01 AM, David wrote:
> Log.objects.distinct('thing__id').order_by('thing__id',
> '-modified_on').select_related().filter(thing__deleted=0)[:20]
>
> By avoiding the use of values() I was able to then use the result as an
> object and access everything
On Apr 12, 4:01 pm, David wrote:
> The above ORM statement however does not look as elegant to read as I have
> come to expect from Django though. The resulting SQL doesn't seem too
> shabby however.
.distinct(fields) + .order_by() is pretty low level stuff - that is
why it
Thank you akaariai
That put me on the right track.
Log.objects.distinct('thing__id').order_by('thing__id',
'-modified_on').select_related().filter(thing__deleted=0)[:20]
By avoiding the use of values() I was able to then use the result as an
object and access everything I needed.
The above
12.4.2012 11:51, David kirjoitti:
Hi Jani
That was very helpful. Is there a way to include select_related into
that query? or do I have to list every single field I would like to
return using values()?
last_deleted = ModificationLog.objects.values('thing__id', ' thing
__prefix', ' thing
On Apr 12, 11:52 am, David wrote:
> > Hi Jani
>
> > That was very helpful. Is there a way to include select_related into that
> > query? or do I have to list every single field I would like to return using
> > values()?
>
> > last_deleted =
>
> Hi Jani
>
> That was very helpful. Is there a way to include select_related into that
> query? or do I have to list every single field I would like to return using
> values()?
>
> last_deleted = ModificationLog.objects.values('thing__id', '
> thing__prefix', ' thing __first_name', '
Hi Jani
That was very helpful. Is there a way to include select_related into that
query? or do I have to list every single field I would like to return using
values()?
last_deleted = ModificationLog.objects.values('thing__id', '
thing __prefix', ' thing __first_name', ' thing__last_name', '
11.4.2012 23:47, David kirjoitti:
Thanks for your reply. I am grateful for your help. If you remember this
question when you feel less sleepy I'd be very interested to see the inner join
alternative :)
Thanks again
Well, after good night sleep I've some idea.
Something like should do the
Thanks for your reply. I am grateful for your help. If you remember this
question when you feel less sleepy I'd be very interested to see the inner join
alternative :)
Thanks again
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this
Hi,
You're not doing anything wrong. The catch is that since "Thing" can exist
without Log you will get outer join.
If you want to get along with inner join, you should turn query around and
start querying from Log model. I'm just too tired to think how it should be
done right now... =)
On
class Log(models.Model):
thing = models.ForeignKey(Thing)
context = models.CharField(max_length=255)
action = models.CharField(max_length=255)
modifier = models.ForeignKey(User, limit_choices_to={'groups__in':
[2]})
modified_on = models.DateTimeField(auto_now=True)
class
12 matches
Mail list logo