Where should django manager code live?

前端 未结 4 2083
无人及你
无人及你 2021-02-01 18:15

This is a pretty simple django patterns question. My manager code usually lives in models.py, but what happens when models.py is really huge? Is there any other alternative patt

4条回答
  •  青春惊慌失措
    2021-02-01 18:55

    I always place mine in managers.py. If you have a circular import issue remember that a) You can reference the model class for a manager at self.model, and b) You can do imports inside of functions.

提交回复
热议问题