• MVC Layer
  • Database Layer : The models are stored in database tables in MySQL. Marvelous Websites Made the Django Way: Models Views
  • Amazing Apps
  • Marvelous Websites Made the




    Download 0,9 Mb.
    Pdf ko'rish
    bet2/8
    Sana26.05.2024
    Hajmi0,9 Mb.
    #254191
    1   2   3   4   5   6   7   8
    Bog'liq
    CCCDjango2010

    Marvelous Websites Made the 
    Django Way:
    Models & Views
    MySQL: Database
    Model 
    Controller
    View 
    User Interface
    (HTTP Output)
    App Layer
    MVC
    Database Layer


    App Layer
    : Outputs
    HTML (controls how data is displayed to the user)
    MVC Layer
     
    1. Model
    : Models contains classes definitions for holding data
    2. View
    : The View controls the access and filtration of data in order to be 
    passed onto the app layer for display. 
    3. Controller
    : The Controller receives and manages inputs to update the 
    Model layer. Additionally, it also updates the elements for the View layer 
    as necessary.
    Database Layer
    : The models are stored in database tables in MySQL.
    Marvelous Websites Made the 
    Django Way:
    Models & Views


    The Django Way


    Amazing Apps

    Django does not work quite like PHP, or other 
    server­side scripting languages

    Django organizes your website into apps

    An app represents one component of a website

    Example: a simple web poll, blog, etc.

    Apps can be used in multiple different 
    websites/projects (“pluggable”), and a website 
    can have multiple apps


    Amazing Apps

    Each app has its own data and webpages associated 
    with it – called 
    models
    and 
    views
    , respectively

    Example: a poll that lets users vote on questions

    Views
    (different webpages):

    Page with questions + choices (actual voting page)

    Statistics page that shows past results

    Models
    (data):

    Poll questions

    Choices associated with each question

    The actual voting data! (set of selected choices)


    Amazing Apps

    When you create an app, Django makes a folder,
    appname/ in your project directory

    It contains, among some other files:

    models.py

    views.py

    urls.py 
    (will be discussed later)

    The app looks like a package (ex., 
    polls.view

    polls.models
    , etc.)



    Download 0,9 Mb.
    1   2   3   4   5   6   7   8




    Download 0,9 Mb.
    Pdf ko'rish