Hi!

You can only use a list of int in this case, because a *__in* option in
exclude expect a list of field type:

Try replace with *pk__in*, like this:

user_list = user_list.exclude(*pk__in*=user_exclude_list)

Cheers.


On Tue, Apr 15, 2014 at 9:04 AM, nobody <[email protected]> wrote:

> Thanks Lucas, but it is the same error:
>
> int() argument must be a string or a number, not 'list'
>
> The id__in is an int argument, but the user_list is a list, I don't see it 
> matchs. I tried to use *user_list, did not work either.
>
>
>
> On Friday, April 11, 2014 8:50:55 PM UTC+10, Lucas Klassmann wrote:
>
>> Hi,
>>
>> Sorry, you must specify the field *ID*, try this:
>>
>> for user in user_object_list:
>>     if user.is_locked():
>>         user_exclude_list.append(user.id)
>>
>> user_list = user_list.exclude(*id__in*=user_exclude_list)  # [1, 3, 4,
>> 5,]  IDs, is more fast
>>
>>
>> Cheers.
>>
>>
>>  On Fri, Apr 11, 2014 at 7:47 AM, nobody <[email protected]> wrote:
>>
>>>  Hi Lucas,
>>>
>>>
>>> On Friday, April 11, 2014 12:07:02 PM UTC+10, Lucas Klassmann wrote:
>>>
>>>> Hi,
>>>>
>>>> You can use *ID* of object for compare with a list and *IN* :
>>>>
>>>> for user in user_object_list:
>>>>     if user.is_locked():
>>>>         user_exclude_list.append(user.*id*)
>>>>
>>>> user_list = user_list.exclude(*user__in*=*user_exclude_list*)  # [1,
>>>> 3, 4, 5,]  IDs, is more fast
>>>>
>>>
>>>  Hmm, I actually got an exception:
>>>
>>> Exception Type: TypeError  Exception Value:
>>>
>>> int() argument must be a string or a number, not 'list'
>>>
>>>
>>> Thanks.
>>>
>>>
>>>
>>>
>>>>
>>>> Cheers.
>>>>
>>>>
>>>> On Thu, Apr 10, 2014 at 9:23 PM, nobody <[email protected]> wrote:
>>>>
>>>>>
>>>>> Thanks Lucas, sorry for not being clear, I like not to include the
>>>>> object when the name is matching, I figured out that can be done to use
>>>>> user_list.exclude, not user_list.filter. It is working currently in an
>>>>> inefficient way:
>>>>>
>>>>> for user in user_object_list:
>>>>>     if user.is_locked():
>>>>>         user_list = user_list.exclude(user__name=user.name)
>>>>>
>>>>> Is there anyway to filter out all users to match the user exclude list
>>>>> in one statement such as following example (wrong syntax I guess):
>>>>>
>>>>>
>>>>> for user in user_object_list:
>>>>>     if user.is_locked():
>>>>>         user_exclude_list.append(user.name)
>>>>>
>>>>> user_list = user_list.exclude(user__name.icontain=user_exclude_list)
>>>>>
>>>>>
>>>>> Thank you.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Friday, April 11, 2014 4:26:23 AM UTC+10, Lucas Klassmann wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> If you want exact match:
>>>>>>
>>>>>> user_list.filter(user__name__iexact=user.name)
>>>>>>
>>>>>>
>>>>>> Or containment test:
>>>>>> user_list.filter(user__name__icontains=user.name)
>>>>>>
>>>>>>
>>>>>> Note that "i" on start is for case-insensitive filtering.
>>>>>>
>>>>>> Look here for more information:
>>>>>> https://docs.djangoproject.com/en/dev/topics/db/queries/
>>>>>>
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>>
>>>>>> On Thu, Apr 10, 2014 at 2:38 PM, carlos <[email protected]> wrote:
>>>>>>
>>>>>>> hi, maybe you filter you queryset
>>>>>>> user_list = Model.objects.filter(user__name=user.name
>>>>>>> ).filter(other__field=user.email)
>>>>>>>
>>>>>>> Cheers
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Apr 10, 2014 at 9:44 AM, nobody <[email protected]> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> How can I filter an item from the queryset object list if the name
>>>>>>>> is matching? The following won't work.
>>>>>>>>
>>>>>>>> user_list.filter(user__name=user.name)
>>>>>>>>
>>>>>>>> Thank you.
>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Django users" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>
>>>>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>>>>> To view this discussion on the web visit
>>>>>>>> https://groups.google.com/d/msgid/django-users/dd1f2a56-1ee7
>>>>>>>> -4dd5-a513-12ef1ef5e83b%40googlegroups.com<https://groups.google.com/d/msgid/django-users/dd1f2a56-1ee7-4dd5-a513-12ef1ef5e83b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Django users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to [email protected].
>>>>>>> To post to this group, send email to [email protected].
>>>>>>>
>>>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>>>> To view this discussion on the web visit
>>>>>>> https://groups.google.com/d/msgid/django-users/CAM-7rO2SDDC%
>>>>>>> 2ByLgdx_Jb%3D021gsonaE9MYn8ZcpTgVEqYv_PoiQ%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAM-7rO2SDDC%2ByLgdx_Jb%3D021gsonaE9MYn8ZcpTgVEqYv_PoiQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Lucas Klassmann
>>>>>> Desenvolvedor de Software
>>>>>>
>>>>>> Email: [email protected]
>>>>>> Web site: http://www.lucasklassmann.com
>>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/django-users/15365d41-a783-4108-88fc-c9b6705257f3%40goog
>>>>> legroups.com<https://groups.google.com/d/msgid/django-users/15365d41-a783-4108-88fc-c9b6705257f3%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Lucas Klassmann
>>>> Desenvolvedor de Software
>>>>
>>>> Email: [email protected]
>>>> Web site: http://www.lucasklassmann.com
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/30d11ad7-51a0-4014-8c70-576122c5cf9b%
>>> 40googlegroups.com<https://groups.google.com/d/msgid/django-users/30d11ad7-51a0-4014-8c70-576122c5cf9b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Lucas Klassmann
>> Desenvolvedor de Software
>>
>> Email: [email protected]
>> Web site: http://www.lucasklassmann.com
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f1e904c9-2993-423c-a202-e88349360977%40googlegroups.com<https://groups.google.com/d/msgid/django-users/f1e904c9-2993-423c-a202-e88349360977%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Lucas Klassmann
Desenvolvedor de Software

Email: [email protected]
Web site: http://www.lucasklassmann.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOz50pLx8RjwrhY7iCj7H80sk-mXhwpUL7iCmc23%2BvG3tbRw2A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to