项目技术栈

目前项目结构

小试牛刀

创建模型

from django.conf import settings
from django.db.models import (
    Model,
    CharField,
    TextField,
    DateTimeField,
    ForeignKey,
    SET_NULL
)


class TestEnvironment(Model):

    name = CharField(max_length=50, null=True, blank=True, verbose_name="测试环境名称")
    user = ForeignKey(settings.AUTH_USER_MODEL, null=True, related_name="author", on_delete=SET_NULL, verbose_name='作者')
    host_address = CharField(max_length=50, null=True, blank=True, verbose_name="环境地址")
    desc = TextField(null=True, blank=True, verbose_name="环境描述")
    create_time = DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        verbose_name = '环境配置'
        verbose_name_plural = verbose_name
        ordering = ("create_time",)

    def __str__(self):
        return self.name

编写视图

class TestEnvironmentViewSet(viewsets.ModelViewSet):

    queryset = TestEnvironment.objects.order_by('-create_time').all()
    serializer_class = TestEnvironmentSerializers

Django Admin

平台接口文档管理

ChangeLog:

  1. 前后台项目初创
  2. 接口文档&admin 集成

下期功能

1.注册、登录、第三方登录 (前后端)
2.单元测试代码编写


↙↙↙阅读原文可查看相关链接,并与作者交流