Astronauts do have toilets in space but the toilets that astronauts use in the spaceship work differently than the toilets we have here on earth.
An astronaut poops into a little plate sized toilet hole and a vacuum sucks the poop away and the pee goes into a separate container that also gets sucked away.
So they do have toilets in space.
Basically astronauts in space can urinate into a long tube with a vacuum system that sucks away the waste or they can sit down on a special spaceship toilet.
The human waste then gets sent out into space and is basically burnt up in the earths atmosphere.
Astronauts can sometimes also wear a diaper while in space and although the space people do not call it a diaper it really is.