1 About the use of serializers in Django (py)
- First define the models
- Then write the serializer
- Then write the view function
- Finally write urls
2 About interface documents in DRF
- write in settings
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
),
"DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema" # 写个接口文档给别人首先导入settings,然后写url
}
- Write configuration in url
from rest_framework.documentation import include_docs_urls
path('docs/', include_docs_urls('DRF Study API')) # 接口文档
2 token configuration URL
3 docker
Configuration URL:
https://www.runoob.com/docker/docker-mirror-acceleration.html
Official documentation:
https://docs.docker.com/engine/reference/commandline/docker/
1 Enter the container and turn it on:
Start the container first: sudo docker container start 13965f3f7365 (id)
Then start: sudo docker exec -it 13965f3f7365 (id) bash
2 container data volume, which means that after the container is deleted, the data will be lost, but the data in the container will not be lost after being synchronized with the local host
Order:
sudo docker run --name ubuntu -it -v /home/bd/docker_test/ubuntu:/home ubuntu bash
Host directory: the directory inside the container
For example mysql database
1. pull image
2. Run the container (anonymous mount: the external data file is not named when mounted)
sudo docker run --name mysql_v1.0 -d -p 3316:3306 -v /home/bd/docker_test/mysql_v1.0/conf:/etc/mysql/conf.d -v /home/bd/docker_test/mysql_v1.0/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=qwe123 mysql:5.7
About mounting:
----------------------------4/5-------------------------
——linux starts mysql
mysql -u admin -p
qwe123
show databases;