Both ex-spouses qualify for the exclusion as long as they both lived in the house before the divorce, and at least one ex-spouse remains in the home after the divorce and meets the qualification rules. Each of you can exclude the first $250,000 of capital gains on their share. If your total gain is less than $500,000 ($250,000 each) then you don't even have to report it unless you previously took a home office deduction or used the property for business or a rental, or you got a 1099-S form at closing. If you did get a form 1099-S, then each of you reports half the purchase price as your basis, half the cost of any improvements, and half the selling price.
However, you can't use the exclusion if you used it on a different home in the 731 days prior to the current closing date. And if you use the exclusion now, you would have to wait at least 2 years before using it again, so if (for example) you have been living in a different house for the last 3 years and think you might sell it soon too, you will have to decide which house to use the exclusion on.
**If a post answers your question, choose it by clicking on "Mark as Best Answer".**