0

I am learning django with practicing. I have one object. It has id, name, lastname. Also, I have one queryset. It has same attributes id,name, lastname. All I want is comparing id's. I can compare ids if they both are equal but my problem is if they both are not equal django gives me error like

matching query does not exist.

because I use filter function.

I want to do this operation

            if icformkeyinput.filter(id=v['Id']):
            if icformkeyinput.filter(id!=v['Id']):

My problem is How can I use != operator?

I want to do this because if there is unmatched id between icformkeyinput and v then add v to icformkeyinput.

nogabemist
  • 402
  • 5
  • 29
  • Does this answer your question? [How do I do a not equal in Django queryset filtering?](https://stackoverflow.com/questions/687295/how-do-i-do-a-not-equal-in-django-queryset-filtering) – Abdul Aziz Barkat Sep 21 '21 at 12:01
  • 1
    Maybe this could help you? [How to check if an element is present in a Django queryset?](https://stackoverflow.com/questions/32002207/how-to-check-if-an-element-is-present-in-a-django-queryset/32002238) – Anna M. Sep 21 '21 at 12:04
  • Thank you Anna. exists() worked. – nogabemist Sep 21 '21 at 12:09

0 Answers0