Django exclude(**kwargs) help

Posted by shawnjan on Stack Overflow See other posts from Stack Overflow or by shawnjan
Published on 2010-04-14T00:10:07Z Indexed on 2010/04/14 0:13 UTC
Read the original article Hit count: 597

Filed under:
|
|

Hey guys/gals!

I had a question for you, something that I can't seem to find the solution for... Basically, I have a model called Environment, and I am passing all of them to a view, and there are particular environments that I would like to exclude. Now, I know there is a exclude function on a queryset, but I can't seem to figure out how to use it for multiple options... For example, I tried this but it didn't work:

kwargs = {"name": "env1", "name": "env2"}
envs = Environment.objects.exclude( kwards )

But the only thing that it will exclude is the last "name" value in the list of kwargs. I understand why it does that now, but I still can't seem to exclude multiple objects with one command. Any help is much appreciated!

Shawn

© Stack Overflow or respective owner

Related posts about django

Related posts about python