MVC and django fundamentals

后端 未结 3 2013
时光说笑
时光说笑 2021-02-08 23:24

Pretty new to this scene and trying to find some documentation to adopt best practices. We\'re building a fairly large content site which will consist of various media catalogs

3条回答
  •  有刺的猬
    2021-02-09 00:23

    "data / architectural models so that we can get a better idea of the approach we should use using a framework we've never made use of before"

    Django imposes best practices on you. You don't have a lot of choices and can't make a lot of mistakes.

    MVC (while a noble aspiration) is implemented as follows:

    • Data is defined in "models.py" files using the Django ORM models.
    • urls.py file maps URL to view function. Pick your URL's wisely.
    • View function does all processing, making use of models and methods in models
    • Presentation (via HTML templates) invoked by View function. Essentially no processing can be done in presentation, just lightweight iteration and decision-making

    The model is defined for you. Just stick to what Django does naturally and you'll be happy.

    Architecturally, you usually have a stack like this.

    • Apache does two things.

      • serves static content directly and immediately
      • hands dynamic URL to Django (via mod_python, mod_wsgi or mod_fastcgi). Django apps map URL to view functions (which access to database (via ORM/model) and display via templates.
    • Database used by Django view functions.

    The architecture is well-defined for you. Just stick to what Django does naturally and you'll be happy.

    Feel free to read the Django documentation. It's excellent; perhaps the best there is.

提交回复
热议问题