An explosive device planted inside a cemetery went off as mourners buried a local teacher killed in an earlier militant attack, the source told Anadolu Agency.