Once you've filed a Chapter 7 bankruptcy you can expect that fact to stay on your credit report for up to 10 years and how quickly you build you credit back up depends on the steps you take to rebuild it. But fortunately for Chapter 7 bankruptcy filers mortgages are handled a bit differently than unsecured loans.
A mortgage is a secured loan, secured by the home, which means that if you don't make timely payments the bank can foreclose on your home and sell it. Because the home itself secures the mortgage, lenders are more apt to give bankruptcy filers a loan than an unsecured lender would. Also, the Fair Housing Administration, or FHA, has rules to protect people who have filed a bankruptcy to help you finance your own home after the Chapter 7 is discharged. Two years after your Chapter 7 bankruptcy is discharged you can typically get approved for a mortgage, but you'll have to jump through some extra hoops to prove that you've gained control of your finances and are ready to responsibly take on debt again.
You can expect to be asked a lot of questions about why you filed bankruptcy which makes sense. Even secured debt lenders are taking on some risk when they make a loan, and they'd much rather deal with someone who was forced into bankruptcy due to circumstances beyond their control, like medical crises and unemployment, than someone who was just foolhardy with their finances.
Your chance of getting a mortgage after a Chapter 7 bankruptcy increase with time and a history of good financial decisions. Some experts suggest waiting more than the required two years before attempting to get a mortgage because the lower interest rate will most likely save you thousands over the lifetime of the loan.