Hi Michal

I a new to django but have been following the tutorial.
I have a question on your answer: Which file would you place this code in
if you wanted to have that filtering visible in the site admin interface.
Would you need to create a custom selection field from which you can pick
to populate the relevant model field? I am not so sure yet how to tie that
in since it looks like its using the DB access API at this stage?

Thanks

Anthony


On Wed, Nov 9, 2011 at 11:03 AM, Michal Petrucha <michal.petru...@ksp.sk>wrote:

> On Fri, Nov 04, 2011 at 11:03:35AM -0700, guardbadger wrote:
> > Hi all,
> >
> > Appreciate some help trying to build a queryset. Im hoping I can make
> > this in django, without having to crack open raw sql... Here is my
> > setup:
> >
> > class Container(models.Model):
> >   permissions = generic.GenericRelation(Permission)
> >
> > class Item(models.Model):
> >   container = models.ForeignKey(Container)
> >   extraSetting = models.ForeignKey(ExtraSetting)
> >
> > class Permission(models.Model):
> >   content_type = models.ForeignKey(ContentType)
> >   content_object = generic.GenericForeignKey()
> >   extraSetting =   models.ForeignKey(ExtraSetting)
> >
> > class ExtraSetting(models.Model):
> >   ....
> >
> > Convoluted made up example, but hopefully you can see what the data
> > might be.
> >
> > So the problem im trying to solve. I need to get a list of items and
> > their permissions, but restrict the permission set so that I only get
> > permissions where extraSetting is the same on the Item and on the
> > permission.
> >
> > So I want to run something like
> >
> >
> Item.objects.filter(container__permissions__extraSetting=Item.extraSetting)
>
> What I think you want to use is this: http://django.me/f
> In your case something like
>
> Item.objects.filter(container__permissions__extraSetting=F('extraSetting'))
>
> Michal
>

-- 
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