Separating Django App Views

前端 未结 4 1139
一向
一向 2021-02-04 06:17

If the app/views.py file gets very large, should I separate it? If so, what is the best way to do this?

4条回答
  •  情歌与酒
    2021-02-04 06:49

    In an ideal world, you shouldn't have to do this. Instead, try to refactor your code into different django apps for each sub-purpose that your project needs. That way, you can partition your project even better than you could have if you only split the views.py file.

    For tips on how to split up your project into different apps, I recommend reading James Bennett's Practical Django Projects, which is what I'm re-reading right now :)

提交回复
热议问题