Split views.py in several files

前端 未结 10 844
有刺的猬
有刺的猬 2020-11-27 09:37

My views.py has become too big and it\'s hard to find the right view.

How do I split it in several files and then import it? Does it involve any speed l

10条回答
  •  野性不改
    2020-11-27 10:01

    Since Django just expects a view to be a callable object, you can put then wherever you like in your PYTHONPATH. So you could for instance just make a new package myapp.views and put views into multiple modules there. You will naturally have to update your urls.py and other modules that reference these view callables.

提交回复
热议问题