当前位置:网站首页>DRF learning notes (preparation)
DRF learning notes (preparation)
2022-07-27 16:18:00 【fresh_ nam】
List of articles
Introduce
drf namely Django REST framework, It provides a definition serializer Serializer Methods , Can be quickly based on Django ORM Or other libraries automatically serialize / Deserialization .
benefits :django You can render pages and return data , But in a specific scenario, you only need to return data ,drf It provides various methods for us to add, delete, modify and check data .
Developing REST API Interface , There are three main things to do in the view :
1. Send the requested data ( Such as JSON Format ) Convert to model class object
2. Operating the database
3. Convert the model class object into the data of the response ( Such as JSON Format )
One 、 Get ready
Environmental Science :
operating system :windows10
python: 3.7
django: 3.1.2
Suggestion editor :pychram
Suggest
Yes django Basics
Two 、 Import and stock in
1、 install drf
pip install djangorestframework
2、 add to rest_framework
In the created django project settings.py add to rest_framework application :
INSTALLED_APPS = [
...
'rest_framework',
]
3、 Database configuration
There should be no problem using the default database ( I've never used ), This will use mysql database , Modify the database settings as follows :
DATABASES = {
'default': {
'ENGINE':'django.db.backends.mysql',
'NAME': 'db_name', // Your data name
'USER': 'username', // Your username
'PASSWORD': 'password', // Database password
'HOST': '127.0.0.1', // Database location
'PORT': '3306' // port
}
}
Preparatory work completed , You can start writing interfaces !
Next chapter :DRF Learning notes ( One ): Data serialization
边栏推荐
- Hematemesis finishing c some commonly used help classes
- QT (VI) value and string conversion
- Keil implements compilation with makefile
- 2.2 JMeter基本元件
- Axure 安装图标字体元件库
- Penetration test - dry goods | 80 + network security interview experience post (interview)
- JMeter5.3 及以后的版本jmeter函数助手生成的字符在置灰无法复制
- JWT简介
- IO流简介
- C language programming (Third Edition)
猜你喜欢

: 0xc0000005: an access conflict occurs when writing position 0x01458000 - to be solved

使用transform:translate()出现内容模糊问题

Security software related to wireless network analysis (airtrack ng)

Solve mt7620 continuous cycle uboot (LZMA error 1 - must reset board to recover)

Axure 安装图标字体元件库

Leetcode 226 翻转二叉树(递归)

Mlx90640 infrared thermal imager temperature sensor module development notes (VII)

解决MT7620不断循环uboot(LZMA ERROR 1 - must RESET board to recover)

Sword finger offer 51. reverse pairs in the array

时间序列——使用tsfresh进行分类任务
随机推荐
突发!海康/大华/商汤/旷视/依图/科大讯飞等28家中国实体被美列入黑名单
无线网络分析有关的安全软件(aircrack-ng)
移动端h5常见问题
Leetcode 226 flip binary tree (recursive)
Characters generated by JMeter function assistant in jmeter5.3 and later versions cannot be copied when they are grayed out
云管平台中租户以及多租户概念简单说明
三星关闭在中国最后一家手机工厂
逗号操作符你有用过吗?
Pychart imports the existing local installation package
makefile 中指定程序运行时加载的库文件路径
Scratch crawler framework
Content ambiguity occurs when using transform:translate()
百度图片复制图片地址
Test novice learning classic (with ideas)
Mapreduce实例(二):求平均值
Single machine high concurrency model design
Embedded development: tips and techniques -- seven techniques to meet the real-time deadline
Keil implements compilation with makefile
flume增量采集mysql数据到kafka
vant-ui toast和dialog使用