oh ok, so just use the filter(user_id = user.id)

On Tue, Sep 29, 2009 at 12:21 AM, luismmontielg <luismmonti...@gmail.com>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 have the user.
>
> Thanks again
>
>
> On 28 sep, 20:16, luismmontielg <luismmonti...@gmail.com> wrote:
> > 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 <josh.r.ru...@gmail.com> wrote:
> >
> >
> >
> > > On Mon, Sep 28, 2009 at 7:55 PM, luismmontielg <
> luismmonti...@gmail.com>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",
> > > > through='ReportDetail', \
> > > >                 symmetrical=True)
> >
> > > > I would like to get all reports from 1 user, but that only contain
> > > > that user
> >
> > > > I was looking for ne, not equals, but its removed, I cant do it with
> > > > the exclude:
> > > > I want to make something like this
> > > > user = User.objects.get(pk=1)
> > > > user_reports = user.report_set.exclude(users__id__NOTEQUAL = user.id
> )
> >
> > > > how can I achieve this?
> >
> > > I'm not sure I completely follow, but user.report_set only gives you
> reports
> > > for the associated user, and it seems like that is what you want. You
> don't
> > > need any further filters or excludes.
> >
> > > For future reference:
> > >     exclude(user_id__ne = user.id)
> > > is the same as
> > >     filter(user_id = user.id)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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