当前位置:网站首页>Innovation training (VII) FBV view & CBV view
Innovation training (VII) FBV view & CBV view
2022-04-23 04:45:00 【Scattered moon】
FBV View
Basic function : Set response function 、HTTP Request object
- Return the response content
- Abnormal response
- Get request information get post
- The crawler
def index ( request) :
# value = {'title': 'this is a test'}
# print(value)
# return render(request, 'index.html', context=value)
# html = '<h1>hello</h1>'
# return HttpResponse(html, status=200)
if request.method == 'GET':
# Class method
print(request.is_secure())
print(request.is_ajax())
print(request.get_host())
print(request.get_full_path())
print(request.get_raw_uri())
# Use of attributes
print(request.COOKIES)
print(request.content_type)
print(request.content_params)
print(request.scheme)
# obtain GET Requested request parameters
print(request.GET.get('user', ''))
return render(request, 'index.html')
elif request.method == 'POST':
# obtain POST Requested request parameters
print(request.POST.get('user', ''))
return render(request, 'index.html')
CBV View
- View class ListView:
You need to use model objects , Defining models , Establish the mapping relationship with the database
command :
python3 manage.py makemigrations
python3 manage.py migrate
- Data operation view
FormView
CreateView
UpdateView
DeleteView
Data display, addition, deletion and modification
版权声明
本文为[Scattered moon]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220555418806.html
边栏推荐
- Create VPC in AWS console (no plate)
- 使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
- Jetpack -- lifecycle usage and source code analysis
- A lifetime of needs, team collaboration can play this way on cloud nailing applet
- Last day of 2017
- leetcode005--原地删除数组中的重复元素
- Brushless motor drive scheme based on Infineon MCU GTM module
- Leetcode004 -- Roman numeral to integer
- QML advanced (IV) - drawing custom controls
- Redis command Encyclopedia
猜你喜欢
Installation du compilateur croisé de la plateforme zynq
Phishing for NFT
Supplement: Annotation
New terminal play method: script guidance independent of technology stack
Unity RawImage背景无缝连接移动
那些年我面试过的Android开发岗总结(附面试题+答案解析)
第四章 --- 了解标准设备文件、过滤器和管道
520. Detect capital letters
Luogu p1858 [multi person knapsack] (knapsack seeking the top k optimal solution)
Recommended scheme of national manufactured electronic components
随机推荐
List remove an element
Flink case - Kafka, MySQL source
Wechat payment function
Practice and exploration of knowledge map visualization technology in meituan
Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
What is the thirty-six plan
Innovative practice of short video content understanding and generation technology in meituan
IEEE Transactions on industrial information (TII)
Record your own dataset with d435i, run orbslam2 and build a dense point cloud
Unity摄像头跟随鼠标旋转
Solutions to the failure of sqoop connection to MySQL
test
ApplicationContext injection bean
leetcode007--判断字符串中的括号是否匹配
The programmer starts the required application with one click of window bat
使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
Leetcode004 -- Roman numeral to integer
[pytoch foundation] torch Split() usage
Experience summary and sharing of the first prize of 2021 National Mathematical Modeling Competition
Unity camera rotation with sliding effect (rotation)