标签:mina key inf length rtm 部门 用户表 name cas
步骤一、创建超级用户:python manage.ply createsuperuser
步骤二、建立数据模型,本次都是以下面的数据模型为例
from django.db import models # Create your models here. class Department(models.Model): """部门表""" name = models.CharField(max_length=32) def __str__(self): return self.name class UserInfo(models.Model): """用户表""" name = models.CharField(max_length=32) email = models.EmailField() dp = models.ForeignKey(to=‘Department‘, on_delete=models.CASCADE) class Role(models.Model): """角色表""" name = models.CharField(max_length=32) users = models.ManyToManyField(to=‘UserInfo‘)
步骤三、在app文件夹下的admin.py中注册模型,如下:
admin.py
from django.contrib import admin
from app01 import models
admin.site.register(models.Department)
admin.site.register(models.UserInfo)
这个步骤的作用是注册模型,新增URL。
步骤四、登陆/admin/来增删改查。
标签:mina key inf length rtm 部门 用户表 name cas
原文地址:https://www.cnblogs.com/Treelight/p/12234407.html