1

if i put below condition in my view file

 id=request.POST['id'] #post data which i am sending from html file
 name=request.POST['name'] #post data which i am sending from html file

 if MyModel.objects.filter(id=id,name!=name).exists():
   print('data available')
 else:
   print('data is not available')

its showing below error

cannot unpack non-iterable bool object

if request.POST['name'] is available in my requested id(request.POST['id']),then i want to print print('data available'). Otherwise i want to print print('data is not available') How to Do that?

  • 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) – JPG Sep 08 '20 at 10:50
  • or, `MyModel.objects.filter(id=id).exclude(name=name).exists()` – JPG Sep 08 '20 at 10:51

1 Answers1

0
results = Model.objects.exclude(name=name).filter(id=id)
Surya Pratap Rana
  • 423
  • 1
  • 4
  • 9