A device for attaching a positioning device to a bone of a patient at a predetermined position relative to a hip implant comprising a trial hip implant and a template. The trial hip implant has a support surface for resting on the bone of the patient The template can be secured to the trial hip implant and has at least one cylindrical opening with a longitudinal axis. The trial hip implant is shaped such that any straight line which runs through one of the at least one cylindrical opening and is parallel to the longitudinal axis of the respective opening does not intersect the trial hip implant when the template is secured to the trial hip implant.