Record some operations in Linux

1 About the use of serializers in Django (py)

  1. First define the models
  2. Then write the serializer
  3. Then write the view function
  4. Finally write urls

2 About interface documents in DRF

  1. write in settings

insert image description here

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
}
  1. Write configuration in url
from rest_framework.documentation import include_docs_urls

    path('docs/', include_docs_urls('DRF Study API'))  # 接口文档

2 token configuration URL

https://blog.csdn.net/m0_47970692/article/details/113407204?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_utm_term~default-2-113407204-blog-124381344.pc_relevant_vip_default&spm=1001.2101.3001.4242.2&utm_relevant_index=5

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

insert image description here

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

insert image description here

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:

insert image description here

----------------------------4/5-------------------------

——linux starts mysql

mysql -u admin -p

qwe123

show databases;

Guess you like

Origin blog.csdn.net/qq_52141227/article/details/130208626