drmet46444 2013-11-18 00:38
浏览 86
已采纳

在django,有像php这样的控制器吗?

This is a follow up question to How can I run a django management command by cron job. I'm trying to get a better understanding of the way to organize code, having come from php MVC frameworks.

In php ( lets say codeigniter ) , A URL will activate a specific controller.

The first answer to the above question states:

One option is, you can create a URL endpoint, and the corresponding view would call the management command.

Without much python/django knowledge, it just seems surprising to me that so you have to get a view involved in running an abritrary app or a controller-like piece of code where no output is needed. Is this really the only way to do this in Django? If so why is it structured this way?

  • 写回答

1条回答 默认 最新

  • duannaoben8011 2013-11-18 08:20
    关注

    You're confusing names with actual things. A view in Django is a piece of Python code that takes a request and returns a response - in other words, exactly what some frameworks would call a controller. What CodeIgniter would call a view, Django calls a template.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划