标签:har OLE app 默认 ssi content 单表 pass 用户表
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘web.apps.WebConfig‘, ‘rbac.apps.RbacConfig‘, ]
from django.db import models class Menu(models.Model): """ 菜单表 一级菜单 """ title = models.CharField(max_length=32) icon = models.CharField(max_length=64, null=True, blank=True, verbose_name=‘图标‘) # 默认值为1 weight = models.IntegerField(default=1, verbose_name=‘显示权重‘) def __str__(self): return self.title class Permission(models.Model): """ 权限表 可以做二级菜单的权限 menu 关联 菜单表 不可以做菜单的权限 menu=null """ url = models.CharField(max_length=32, verbose_name=‘权限‘) title = models.CharField(max_length=32, verbose_name=‘标题‘) menu = models.ForeignKey(‘Menu‘, null=True, blank=True) # 自己关联自己 parent = models.ForeignKey(‘self‘, null=True, blank=True) # 写法二 # parent = models.ForeignKey(‘Permission‘, null=True, blank=True) name = models.CharField(max_length=32, verbose_name=‘URL别名‘) class Meta: verbose_name_plural = ‘权限‘ verbose_name = ‘权限‘ def __str__(self): return self.title class Role(models.Model): """ 角色表 """ name = models.CharField(max_length=32, verbose_name=‘名称‘) permissions = models.ManyToManyField(‘Permission‘, verbose_name=‘角色拥有的权限‘, blank=True) def __str__(self): return self.name class User(models.Model): """ 用户表 """ name = models.CharField(max_length=32, verbose_name=‘名称‘) password = models.CharField(max_length=32, verbose_name=‘密码‘) roles = models.ManyToManyField(‘Role‘, verbose_name=‘用户拥有的角色‘, blank=True) def __str__(self): return self.name
标签:har OLE app 默认 ssi content 单表 pass 用户表
原文地址:https://www.cnblogs.com/bigc008/p/10202101.html