This time I will bring youdjangoControland detailed explanation of the use of passing parameters. What are theprecautionsfor using Django controls and passing parameters? Here is the actual combat Let’s take a look at the case.
This article introduces the single selection and multi-selection in the djangoHTML form control, and explains how to pass parameters.
1. Form controls in HTML:
Forms are generally written in HTML as:
The overall structure of the previous paragraph in HTML is
Then the previous HTML is like this.
2. Accept data in django’s view.py:
The backend can write a def in the view to accept the data passed in by the frontend:
Such as:
def receive_data(request): if request.POST: # 如果数据提交 print('有提交') select = request.POST.get('select',None) text = request.POST.get('text',None) print(select,text) return render(request,'your_html.html', locals()) # your_html.html改为你的html页面并且参考前面的博客建立url链接。
This is a simple case of django creation before and after interaction, conducted under django 1.10.5python3.5 html 5.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
Echarts implements dynamic color-changing histogram
jquery implements all-select and inverse-select radio selection
jQuery operation background color gradient animation effect
The above is the detailed content of Detailed explanation of the use of Django controls and parameter passing. For more information, please follow other related articles on the PHP Chinese website!