is Flask an MVC or MTV?

26,387

As the homepage puts it, it's a microframework. It's not an MVC (for one, there's no model in flask -- however, you can combine it with something like SQLAlchemy), and I'm not sure what you mean by MTV. It's basically a wrapper around werkzeug which is a wrapper around pure WSGI. A wrapper with templating abilities.

Edit: Also, what does it matter what the terminology is? Just browse the docs, see what it can do and figure out if it's good for you or not :)

Share:
26,387
Abdelouahab
Author by

Abdelouahab

print "Hello world"

Updated on July 05, 2022

Comments

  • Abdelouahab
    Abdelouahab almost 2 years

    and sorry for that question

    but it seems that i dont get what is really Flask, it comes with a Template engine like the one used in django, so is it an MTV?

    and each time i see something related to MVC and Python, there is Turbogears and Django, so how about Flask?

  • Abdelouahab
    Abdelouahab over 12 years
    mtv is what django uses, mtv means Model Template View, and the concept is made to "cut" the project in parts, to simplify the work of a team, so the programmer will have its own job, and the webdesigner will have its job too, in the separate way, but in the final result, it will be the joins of the two :)
  • Felix
    Felix over 12 years
    Well, MTV is not really a thing. As this page puts it, it is slightly different from the traditional MVC pattern. Also, wikipedia describes django as an MVC framework.
  • Abdelouahab
    Abdelouahab over 12 years
    yes, i've read a lot of articles about the "confusion" between the two concepts!
  • Felix
    Felix over 12 years
    There's no confusion. They're actually the exact same thing. The Django devs just use different names for the view (template) and the controller (view), but in essence they are the same thing as in any other MVC framework. The only confusion is actually calling Django an MTV framework, since it can lead you to think it's a different concept. It is not. Here's the Django devs' explanation.
  • Abdelouahab
    Abdelouahab over 12 years
    so a microframwork can't be an MVC? it separates the view and the model and the controller, so it can't be called neither MVC nor MTV?
  • Felix
    Felix over 12 years
    It's just terminology. They called it a microframework to symbolize the fact that it's a framework and that it's small. Yes, someone could make a piece of software and call it an MVC microframework, but flask is not that. There's no dictionary definition for either one of these terms (framework, microframework, MVC).
  • sojin
    sojin over 12 years
    @abdel, This MVC terminology doesn't really fit to the Web world. If you clearly observe the pattern of a typical Web framework, it would be something like this:- You type a url, which is mapped to a view function which returns the response/page(it could be from a Model or from a Template or from both). The notion of controller doesn't' suits here. That's why Django is MTV, Pyramid is RV, etc. As Felix rightly said, it doesn't matter what the terminology is, see if a framework suits your needs, then go for it.
  • Abdelouahab
    Abdelouahab over 12 years
    Felix; so i can call it an MTV? sjn; but the problem is that i want to make some definition to the framework, so i cant to classify it, and because we already studied about MVC i wanna give the definition in my thesis to give some idea about how the framework behaves
  • Felix
    Felix over 12 years
    As I said, MTV === MVC. It's stated clearly in the Django docs. And no, you can't call it an MTV, because it's not. It is just a framework. It doesn't have to be anything else, and it's not.
  • Abdelouahab
    Abdelouahab over 12 years
    so from the link you gave me, docs.djangoproject.com/en/dev/faq/general/… i think it's called MT, because the V (as in django the controller or the C ) it's the django itself from the page, so am really confused, because Flask runs in Jinja (dependecies) and it's the same as the Template in django, and model, it's the same in django with the call of python functions....:(
  • Felix
    Felix over 12 years
    You make no sense. Django is a framework with an MVC pattern. It's not MTV, it's not MT. Flask is just a framework. It's not MVC, not MTV, not MT. You are overthinking this. Badly.
  • Abdelouahab
    Abdelouahab over 12 years
    sorry, maybe i dident understood well, or i asked my question in a bad way, but the MVC (or MTV...) is only a pattern, so it's used to show a "philosophy" of that software (or framework), so does Flask obey to the MVC pattern? (since mvc is the same as mtv) because it separate the template (what a web designer will do) from the functions (what a python programmer will do)
  • Felix
    Felix over 12 years
    As I said in my original answer, no. It does not obey the MVC pattern since it does not have a model. It only has the view (jinja2 templates) and the controller (your actual app).
  • Abdelouahab
    Abdelouahab over 12 years
    ahhh!! now i understand, so if it has for example SQLAlchemy bundled or as a dependency it will be a complete MTV! thank you :) and as i said, Flask maybe a VC or TV? ^_^