What is the difference between the MVC architecture and Django’s MTV?

Asked

Viewed 2,633 times

4

I wonder if there is any difference in practice between these two architectures.

  • 2

    This explains why the name MTV: https://docs.djangoproject.com/pt-br/1.11/faq/general/, if no one formulates an answer, I may later risk something.

  • No one can help?

2 answers

2

This is just a more conceptual issue. Django developers understand that the controller is the framework itself. If we stop to think this makes sense, since when you access some url of your application, the Django engine itself redirects to the correct view, as you have defined in the url settings, that is, it is understood here that the role of the controller is already being carried out automatically. Therefore, the method or class that will process what will happen when this specific page is accessed has been called view. Finally, the way your page will be displayed (using the view’s variable dictionary) consists of a template.

I hope I’ve really helped!

2


Basically 'it’s a question of nomenclature, the Django view' is exactly the equivalent of the controller in MVC. Ja the template (MTV) and the html file rendered by the view (controller) that would be the equivalent of the view in MVC

Model ( models.py) Template ( rendered HTML file ) View ( views.py controller equivalent in MVC )

  • Django’s "view" is not exactly the "controller" of the MVC: https://docs.djangoproject.com/pt-br/3.0/faq/general/#Django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-Names

Browser other questions tagged

You are not signed in. Login or sign up in order to post.