[Answered ]-How can exclude the item which is in db Django

1👍

Looks like you overcomplicated it a bit and just want:

Order.objects.exclude(orderrequest__order_status=status)

Right now you’re trying to exclude Order records where Order.orderrequest.order_status is in a QuerySet of OrderRequest objects, which it never will be, so nothing is being excluded.

As to the second part of your question, I recognize this from an earlier question you posted. You’ve still included selected in all of your <option> tags. If the word selected is in there at all, the item will be treated as selected, even if it says selected="please God no". The proper way to mark an <option> as selected is:

<option value="some_value" selected>

👤Dave

Leave a comment