Use the aggregation way:
user.report_set.annotate(count = Count('report_set')).filter(count =
1)
On Sep 29, 10:39 pm, luismmontielg wrote:
> yeah, something like that is what I want, but to me, that is not the
> best way of doing it ...
> Maybe there's a simpler way?
>
> thanks in advance
>
> On
yeah, something like that is what I want, but to me, that is not the
best way of doing it ...
Maybe there's a simpler way?
thanks in advance
On Sep 29, 8:46 am, sunn wrote:
> This should hopefully work as well
> user_reports = user.report_set.exclude(users__id__lt = user.id,
> users_id_gt = use
This should hopefully work as well
user_reports = user.report_set.exclude(users__id__lt = user.id,
users_id_gt = user.id)
On Sep 29, 4:32 pm, sunn wrote:
> If you don't want to write SQL I think the easiest way is to combine
> two querysets
>
> # You can combine queries with & and |.>>> s1 =
>
If you don't want to write SQL I think the easiest way is to combine
two querysets
# You can combine queries with & and |.
>>> s1 = Article.objects.filter(id__exact=1)
>>> s2 = Article.objects.filter(id__exact=2)
>>> s1 | s2
[, ]
>>> s1 & s2
[]
From
http://www.djangoproject.com/documentation/mod
that brings me all reports that have that user, but also the reports
that have user and user2.. i want only the reports that have 1 user
and id is equal to user.id
On Sep 29, 4:35 am, Joshua Russo wrote:
> oh ok, so just use the filter(user_id = user.id)
>
> On Tue, Sep 29, 2009 at 12:21 AM, lui
oh ok, so just use the filter(user_id = user.id)
On Tue, Sep 29, 2009 at 12:21 AM, luismmontielg wrote:
>
> Actually there it is,
>
> users = models.ManyToManyField(User, symmetrical=True)
>
> but I want to filter only the reports that contain only this user, or
> exclude the ones that do not hav
Actually there it is,
users = models.ManyToManyField(User, symmetrical=True)
but I want to filter only the reports that contain only this user, or
exclude the ones that do not have the user.
Thanks again
On 28 sep, 20:16, luismmontielg wrote:
> sorry forgot to mention its a many to many rela
sorry forgot to mention its a many to many relation so a report can
have multiple users
On Sep 28, 4:29 pm, Joshua Russo wrote:
> On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg wrote:
>
>
>
>
>
>
>
> > Hello,
> > I have my models like this...
>
> > class Report(models.Model):
> > title = mode
On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg wrote:
>
> Hello,
> I have my models like this...
>
> class Report(models.Model):
>title = models.CharField(max_length=50, blank=True)
>users = models.ManyToManyField(User, symmetrical=True)
>categories = models.ManyToManyField("Category",
On May 19, 12:11 pm, Lokesh wrote:
> class Users(models.Model):
> userId = models.IntegerField(max_length=2, primary_key=True)
> userName = models.CharField(max_length=10, null=False,
> blank=False)
>
> def __unicode__(self):
> return self.userName
>
> class MotherTongue(model
10 matches
Mail list logo