Dragonboard 410c is equipped with web server back-end data interaction

I. Introduction:

In this series of articles, bloggers have introduced several Python django architecture application examples, including web user registration and login system, blog system, user video upload, etc. I believe that children’s shoes that have been viewed by bloggers should be Attracting django's simple and practical code architecture, today we will share how the front and back data of the Django architecture interact.

2. Data interaction:

1. Concept: Before analyzing data interaction, first understand several important concepts.

1.1. Front-end: For the website, the front-end usually means that the front-end part of the website includes the presentation layer and the structural layer of the website. Therefore, the front-end technology is generally divided into front-end design and front-end development. The front-end design can generally be understood as the visual design of the website. The front-end development is the front-end code implementation of the website. To put it bluntly, it is the interactive page that you see when you open the web page and its display. Some special effects, front-end code implementations include basic HTML and CSS, and JavaScript/ajax, now the latest advanced versions of HTML5, CSS3, and SVG.

1.2. Backend: Also known as the background, sometimes referred to as the website management background, refers to a series of operations used to manage the front end of the website, such as: product, enterprise information addition, update, deletion, and so on. Through the website management background, you can effectively manage the information that the website can view for viewers. The background of the website usually requires the login verification of the account and password information. The login information is verified and then enters the management interface of the website background to perform a series of related operations. The front desk completes the simple webpage and has almost no functionality; Works can be called web applications, they can achieve certain application functions, that is, the work of the background staff is programming. From simple message boards to complex forums, from simple personal website systems to complex content management systems (CMS), they can be called web applications.

1.3. HTML: Hypertext Markup Language, an application under the standard universal markup language. "Hypertext" means that the page can contain images, links, and even non-text elements such as music and programs. The structure of the hypertext markup language includes the "head" part (English: Head) and the "body" part (English: Body), where the "head" section provides information about the web page and the "body" section provides the specific content of the web page.

2. Data interaction mode:

2.1 Background Data Transfer Front End: Renders the contents of a list or dict directly in the view function (the function in views.py) and displays it on the web page along with other parts of the web page (either one time, or the same request)

View.py

Def index(req):
Username = req.COOKIES.get('username','')
User_list=getAllUser(req)# retrieves all user objects with username and id
Return render_to_response('login_user.html' ,{'user_list': user_list,'username':username})

Part of the code in login_user.html

2.2. Front-end data transmission background:

Part of the code in the front end html:

Lang= "en" class= "no-js" >
Class= "page-container" >
Class= "wrapper" align= "left" >
  • Select private object

    {% for item in user_list %}
    Type= "radio" name= "radio-btn" class= "regular-radio" value= {{ item . id }} /> {{ item.username }} />
    {% endfor %}
    Style= "text-align:center;" >