Yes, but you may have to shop around a bit. Each landlord has the discretion to rent to a particular tenant based on a number of legal factors, including the landlord’s determination of a tenant’s ability to pay the mortgage each month.
The landlord’s ultimate decision may depend on the circumstances that led up to the bankruptcy and a number of other factors, such as recommendations from previous landlords or other personal references. Most landlords will evaluate whether the bankruptcy was caused primarily by an unexpected event, such as medical bills following a serious accident, or by financial irresponsibility.
As a practical matter, the ability to rent an apartment in the future should not be a significant factor in making your decision about whether to file bankruptcy. The amount of your unpaid debts, by itself, may jeopardize your chances, even if you don't file bankruptcy. In that sense, not filing for bankruptcy may make you more of a financial risk due to the size of your outstanding debts. By the same token, using a government-approved means of dealing with your debts may actually be viewed as an indication of financial responsibility.
Honesty is often the best policy. If you know your prospective landlord will be running a credit check, be up-front and honest about what your credit contains, and the reason for your past financial difficulty. While you may need to provide more information to convince a prospective landlord, there are still many landlords who are willing to rent to tenants with a bankruptcy in their past.