15

Learning Django MVC and the way I thought of it is:

Models are the database tables represented in Django as Python classes.
Views are the HTML returned from function in views.py.
Controllers are the actual functions themselves in views.py invoked from a HTTP request.

However I read on Wikipedia (at the time of writing):

... a regular-expression-based URL dispatcher ("Controller").

I would have thought the mapping of URLs to functions as routing - not the controller. But perhaps I am wrong - I guess I got my ideas because is ASP MVC the functions that handle the requests are contained in classes called Contollers...

InformedA
3,0412 gold badges22 silver badges30 bronze badges
asked Aug 2, 2014 at 10:18

1 Answer 1

18

Your thoughts are not wrong. In MVC web-frameworks, people often speak of a Base Controller that performs the routing of a request to the actual Controller that handles the request.

This has come about because web frameworks generally have a single point where the request is received by the application and in pure MVC terms, this is where the job of the Controller starts.


The Django framework uses a non-idiomatic way of naming the parts of the MVC triad.

The mapping between Django names and the idiomatic terminology is:

Idiomatic term | Django term | Meaning
Model | Model | Contains all the business logic. At the very least the database access logic
View | Template | Responsible for generating the HTML and other UI
Controller | View | Contains the logic to tie the other parts together and to generate a response to a user request
answered Aug 2, 2014 at 11:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.