Django views architecture

柔情痞子 提交于 2019-12-12 21:22:46

问题


I'm new to django and had a question regarding organizing views. manage.py startapp creates a views.py in my app folder. But django-admin.py startproject <name> does not create a corresponding views.py file in the <project_name>/<project_name> folder.

I find it intuitive to have global views which do not correspond to a particular app. For example, a login page would and should be independent of any app that I create (its associated with the django auth app). So, would it make sense to create another views.py in the <project_name>/<project_name> folder where I can define such views?

(Just wanted to run it by experienced djangoers before I proceed.)

Thanks.


回答1:


  • You can write your global views anywhere. it can be in any file name (I use, global_views.py)
  • I used to write a global to overrride/customize the default framework apps like custom authentication backend and custom sites.
  • Better to create a custom app and write all the global views.


来源:https://stackoverflow.com/questions/10526256/django-views-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!