
255 Cal.App.2d 523 (1967)
ELLEN DOREENE NADLER, Petitioner,
v.
THE SUPERIOR COURT OF SACRAMENTO COUNTY, Respondent; WALTER ROBERT NADLER, Real Party in Interest. [255 Cal.App.2d 524]
Civ. No. 11775. 
California Court of Appeals. Third Dist.  
Oct. 30, 1967.
 Clarence S. Brown and Clyde M. Blackmon for Petitioner.
 No appearance for Respondent.
 Ernest F. Winters for Real Party in Interest.
 THE COURT.
 Petition for a writ of mandate brought to compel the Superior Court of Sacramento County to hear further testimony and take additional evidence on the issue of the effect of petitioner's homosexual conduct upon the well- being of petitioner's daughter. The father of the child has appeared herein as the real party in interest.
 This proceeding arose out of a divorce action brought by petitioning wife, and subsequent child custody proceedings therein. It is unnecessary to set forth in detail the various legal proceedings taken in this matter, as we are here concerned only with the order of the Sacramento Superior Court, filed October 5, 1967, awarding custody of petitioner's daughter--aged five--to the father and the basis of such order as grounds expressed by the court. The pertinent part of that order reads as follows:
 "The court finds from the evidence and stipulations by counsel for the parties hereto that:"
 "1) The Plaintiff is a homosexual female engaging in sexual acts with other females."
 "2) The homosexuality of plaintiff as a matter of law constitutes her not a fit or proper person to have the care, custody and control of ... the minor child of the parties hereto, therefore, it will be for the best interest and welfare of said minor child to now place her in the custody of her father, defendant herein."
 The net effect of this order is to remove the child from petitioner for the sole reason that petitioner is a homosexual female and therefore not a proper person to have custody of her daughter as a matter of law. An undenied allegation declares that the trial judge stated in court that he was not exercising his discretion and was required as a matter of law to award custody to the father. Both sides stipulated in the trial court that both the mother and father were able and willing to provide the child with physical care and support.
 [1] In a divorce proceeding involving the custody of a child, primary consideration must be given to the welfare of the child. (Sanchez v. Sanchez, 55 Cal.2d 118, 121 [10 Cal.Rptr. 261, 358 P.2d 533]; Gudelj v. Gudelj, 41 Cal.2d 202, 208 *525 [259 P.2d 656]; see also Civ. Code,  138, subd. (1).) The good of the child must be regarded as the controlling force in directing its custody. (See Crater v. Crater, 135 Cal. 633, 634 [67 P.2d 1049].)
 [2] It is also the rule that the matter of the custody of a minor is vested in the trial courts, and these courts are given a very broad discretion in determining the best interest of the child. (Prouty v. Prouty, 16 Cal.2d 190, 191 [105 P.2d 295].) Both of the foregoing rules are succinctly set forth by the Supreme Court in Taber v. Taber, 209 Cal. 755, at pages 756 - 757 [290 P.2d 36]: "[T]he trial court is necessarily allowed a wide latitude in the exercise of its discretion. In the first instance it is for the trial court to determine, after considering all the evidence, how the best interests of the child will be subserved. The question is to be determined solely from the standpoint of the child, and the feelings and desires of the contesting parties are not to be considered, except in so far as they affect the best interests of the child."
 [3] If additional emphasis be needed, it is not until the trial court has considered all the evidence that it may exercise its discretion as to how the welfare of the child will best be served. We are not saying here that the trial court abused its discretion. Rather, we are saying that the trial court failed in its duty to exercise the very discretion with which it is vested by holding as a matter of law that petitioner was an unfit mother on the basis that she is a homosexual.
 We therefore hold that the trial court erred in failing to exercise its discretion and ruling as a matter of law that petitioner was an unfit mother.
 [4] Mandate is an appropriate remedy to compel the exercise of discretion by a trial court when the court has refused to exercise its discretion because of a mistaken belief that it had none. (Erlich v. Superior Court, 63 Cal.2d 551, 556 [47 Cal.Rptr. 473, 407 P.2d 649].)
 Let a peremptory writ of mandate issue directing the superior court to vacate its order of October 5, 1967, and to exercise its discretion in awarding the custody of the child. Counsel are at liberty to stipulate to the issuance of a peremptory writ forthwith. *526
