Praise be to Allah
The bleeding that occurs with childbirth is called nifaas (post-partum bleeding).
There is no minimum limit for nifaas. It may last for ten days or for a week, or less than that. The maximum limit of nifaas is forty days according to the more correct scholarly opinion.
Please see the answer to question no. 10488.
The end of menses can be determined by one of two signs:
i. Emission of the white discharge, which is well-known to women.
ii. Complete dryness, so that if a piece of cotton or the like is inserted into that place, it comes out clean with no trace of blood or yellow on it.
If you see one of the two signs, then you should do ghusl, pray and fast. If the bleeding stops but there is not complete dryness, then this means that nifaas is still ongoing. If it lasts for more than forty days, then this is istihaadah (non-menstrual bleeding), unless it coincides with the usual time of your period, in which case it is menses.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked about a woman who saw the blood of nifaas for two weeks, then it gradually turned into mucus that was yellowish in colour, and it continued like that until the end of the forty days. Do the rulings on nifaas apply to this discharge that followed the bleeding, or not?
He replied: With regard to this yellowish discharge or mucus, so long as no clear signs of purity (i.e., the end of nifaas) appear in it, it comes under the same rulings as the blood nifaas. So the woman is not pure until this ends.
End quote from Fataawa al-Mar’ah al-Muslimah, p. 304.
Based on that, so long as the bleeding has not ceased completely, you are still in nifaas, so it is not valid for you to fast.
And Allah knows best.