The astrotracer function is available for Pentax cameras built after 2010, meaning that unfortunately models like the K-7, K-10, K-100, K-20, K-200, K-x and K-m don't have the astrotracer function. The "Notes about lenses" section discusses aspects to consider when choosing a lens.
What to shoot: A church with a starry background ? or Rho Ophiuchi nebulosities ?
To know what will be up in the sky and in what direction it will be visible, familiarize yourself with the use of planetarium apps like SkySafari or Stellarium and "learn" your sky.
Apps like the Photographers Ephemeris or Photopills can tell you where to place yourself to get the view you want, like here on the left image, the app helped me know in advance where I needed to be to align the church with Orion.
Go to the "What it can do" section for more tips about shooting these targets
How bright is your sky ?
Locate the site you'll be observing from on the Dark Sky Finder. The sky in the red, silver and white areas is so brightly illuminated by city lights that you'll hardly see any stars from there and the camera won't do better. I shoot mostly from yellow and green areas but blue and black are the best.
Playing with camera settings
Exposure time: My experience with APS-C: max 60 - 90 s with lenses shorter than 24 mm; up to 90 - 180 s with lenses 24 to 50 mm and up to 40 - 60 s with lenses 70 to 135 mm.
F/stop: As wide as the lens allows without loosing too much details. Between f/2 to f/2.8 is excellent, above f/4 is too dark.
ISO setting: Lots of theories out there, you'll have to make your own mind. ISO 800 is a good starting point.
Take your time to focus
Nothing worse than realizing you lost 4 hours of your time shooting the night sky getting blurry images because you didn't take that extra minute to carefully check focus on your lens.
With wide angle lenses it really is a matter of trial and error because live view max magnification is not always reliable. But with lenses 35 mm and longer it is the method I use.
Bahtinov masks that you put in front of the lens apparently work great but I haven't tried them yet.
Shoot!
Everything is set now is time to shoot! The following sections will provide information about using the astrotracer itself and post-processing your shots.
Have fun and don't forget to take time to stargaze, the picture is just a souvenir!