  For any ring $A$ and a small, preadditive, Hom-finite, and locally bounded
category $Q$ that has a Serre functor and satisfies the (strong) retraction
property, we show that the category of additive functors from $Q$ to the
category of (left) $A$-modules has a projective and an injective model
structure. These model structures have the same trivial objects and weak
equivalences, which in most cases can be naturally characterized in terms of
certain (co)homology functors introduced in this paper. The associated homotopy
category, which is triangulated, is called the $Q$-shaped derived category of
$A$. The usual derived category of $A$ is one example; more general examples
arise by taking $Q$ to be the mesh category of a suitably nice stable
translation quiver. This paper builds upon, and generalizes, works of Enochs,
Estrada, and Garcia-Rozas and of Dell'Ambrogio, Stevenson, and Stovicek.
