django: Fat models and skinny controllers?

前端 未结 3 1157
青春惊慌失措
青春惊慌失措 2020-12-24 03:16

This is a general architecture question. I read in many places that in an MVC framework, (1) models ought to be fat, and controllers ought to be skinny. But I also read th

3条回答
  •  隐瞒了意图╮
    2020-12-24 03:53

    It depends of what your application is about, but the beauty of Django is that it does not enforce you to put your logical code in your views or in your models, this is your call.

    If you think that some logic is strongly related to your model then you can make a method of it. The rule (for me) is that your model should be agnostic about the environment (web-app, Crontab running a manage command, etc).

    My policy is to try to put the bare minimum in my models.

    By the way, you don't plan to handle request and sessions in your models don't you ? that is a bad idea.

提交回复
热议问题