Problem: Armature deforms mesh when after parenting I am fairly new to Blender and recently I've been working on a new character rig from scratch. I've got the character mesh all drawn out and right now I'm learning from online tutorials on youtube on adding armature to the character. It's been slow but steady progress, until I ran into some problems that I can't solve or find any solution to overcoming them.

This picture below shows my character mesh and the armature I've created before parenting them together.



As you can see, everything looks fine, the mesh is still perfectly normal and proportionate, the bones are all facing the right direction. I've added 4 IK bones to the back of the wrists and ankles and changed the chain length to 2 under bone constrains. Initially, the bones at the knees were bending at an awkward angle, but I've twisted them back to a normal position by adjusting the pole angle.

However, the problem arises when I did the parenting of the armature to the character mesh. Following instructions from a youtube armature tutorial, I went into object mode, clicked on the mesh, then on the armature, before using Ctrl+P to set parent with automatic weights.

The picture below shows the deformation.



As you can see, the Abdomen area is oddly twisted, the Upper Leg and Lower Legs are twisted and an unusual angle. Strangely, the feet are still facing the right way. The knees also bend the intended way, but the Upper legs joining to the Abdomen is twisted.

I know you guys can probably tell there's a stupid thing I overlooked (I'm a noob), but I'm literally at wit's end.

Please help me with some detailed explanation on how I can go about solving this problem. I've watched Sebastian Lague's video on The Basics of Character Rigging. Your help will be greatly appreciated!
I've managed to solve my own question :D

Turns out I found a useful tutorial which suggested that I first bend the bones slightly in edit mode before parenting the armature to the mesh.

It works now!