from django.db import models
# Create your models here.from django.contrib.auth.models import AbstractUser
classUserInfo(AbstractUser):
gender = models.IntegerField(choices=((1,'男'),(2,'女'),(0,'未知')),null=True)
age = models.IntegerField(null=True)
phone = models.CharField(max_length=11,null=True)
3.1.2 serializer.py
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
classLoginSerializer(TokenObtainPairSerializer):defvalidate(self, attrs):
res =super().validate(attrs)
user = self.user
data ={'code':100,'msg':'登录成功','username': user.username,'gender': user.get_gender_display()}
data.update(res)return data
3.1.3 views.py
from django.shortcuts import render
# Create your views here.import json
from rest_framework.views import APIView
from rest_framework.response import Response
classFilmView(APIView):defget(self, request):withopen('./film.json','rt', encoding='utf-8')as f:
res = json.load(f)return Response(res)
3.1.3 urls.py
from django.contrib import admin
from django.urls import path
from rest_framework_simplejwt.views import token_obtain_pair
from app01 import views
urlpatterns =[
path('admin/', admin.site.urls),
path('login/', token_obtain_pair),
path('film/', views.FilmView.as_view()),]
由于使用的激光雷达是网口输出的,
为了不占用X3派已有的网口,接上去了一个绿联的usb网卡,
发现系统没有驱动,所以动手看看能不能自己编译一个
首先lsusb查看一下网卡型号 发现型号是AX88772B,去官网看了一下,发现官方提供驱动
AX88772B - Low-Power USB 2.0 to Fast …