What is a more efficient way to pass variables from Template to View in Django?

后端 未结 2 1125
梦如初夏
梦如初夏 2021-02-03 11:08

My question involves passing variables from the template to view in Django.

I know of passing variables in the URL and through a form. The problem I have with the first

2条回答
  •  隐瞒了意图╮
    2021-02-03 11:16

    There are three ways to get data from an html page into the server backend: URL (GET), Form (POST), and Cookies.

    Any of the three may be manipulated so you need to validate everything on the server every time no matter what.

    In terms of efficiency, per your post title, URL (GET) variables a slightly more efficient since form data goes through a mild amount of encoding before it is sent on to the server.

    Under normal usage the standard is to use URL (GET) variables when you are retrieving data from the server and to use Form (POST) variables when you want to manipulate (edit/delete) data on the server.

提交回复
热议问题