Separating Django App Views

前端 未结 4 1181
一向
一向 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条回答
  •  Happy的楠姐
    2021-02-04 06:37

    I'd separate out views with similar purpose or functionality into one file, and include that in views.py. I only do this for readability and maintenance. For instance, CRUD views for a particular object or group of objects.

    By importing these views directly into the main views.py file, it allows people not familiar with your convention to find what's where.

    views/object_view.py
    

提交回复
热议问题