You can have one spouse pay for divorce attorney for the other spouse, in certain circumstances. The easiest would have an agreement with your spouse that this will be part of the divorce settlement. If agreed upon in advance by both parties, it is certainly allowed for one spouse to pay for both attorneys. If your spouse is not immediately agreeable to this plan, it is important that you discuss this very early on with your divorce attorney.
In order to do the best job representing you, your attorney needs to have a complete and accurate picture of your financial situation. It may be that you have been a non-working spouse and that you do not have the financial means to retain an attorney, but that your spouse can well afford the expense. If you make your divorce attorney aware of this up front, he or she can begin working on making arrangements and negotiating for your spouse to cover your legal costs.
If your spouse is still not agreeable, then a judge will make a decision after reviewing financial statements from both parties, and also considering the specifics of the case if it is fault divorce. Laws do vary by state, and judges have latitude to make broad decisions, but in general you are likely to get your attorney fees paid by your soon to be ex-spouse if you can show that:
Talk to a divorce attorney as soon as you think that divorce is going to be your only option. An attorney will be able to give you a different perspective on the things that you need to consider as you prepare for divorce, and can help you get your attorney fees paid for if it is necessary.