# testDemo **Repository Path**: only-sheep/test-demo ## Basic Information - **Project Name**: testDemo - **Description**: Django的远程面试编程题 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-06 - **Last Updated**: 2022-07-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: Python, Django, Git ## README # README ## 1、依赖安装 > ```bash > python==3.8.7 > asgiref==3.5.2 > Django==3.2 > djangorestframework==3.12.4 > pytz==2022.1 > sqlparse==0.4.2 > ``` ## 2、接口介绍 | 接口 | API | | ------------------------------ | ------------------------------------------------------------ | | 输入性别返回对应学生和所属班级 | GET:http://127.0.0.1:8000/test/user/ 请求体数据:"sex":ID> | | 删除学生数据 | DELETE:http://127.0.0.1:8000/test/user// | | Fibnacci数组 | GET:http://127.0.0.1:8000/test/fibnacci/ 请求体数据:"num":number> | ## 3、数据库模型类定义 /model.py ```python from django.db import models from django.contrib.auth.models import User # from django.contrib.auth.models import AbstractUser # Create your models here. class Classes(models.Model): name = models.CharField(verbose_name="班级名称", max_length=32) class Meta: db_table = "classes" class Student(models.Model): sex_choice = ( (0, "女"), (1, "男"), ) user = models.OneToOneField(User, on_delete=models.CASCADE) sex = models.IntegerField(verbose_name="性别", choices=sex_choice, default=1) owner_class = models.ForeignKey(verbose_name="班级", on_delete=models.CASCADE, to=Classes) ``` ## 4、斐波那契数组 `时间复杂度`**:O(n)** /utils.py ```python def get_fibnacci(num): num_list = [] a, b = 0, 1 for i in range(num): a, b = b, a + b num_list.append(a) indexs = num - 2 return num_list[indexs] ```