UniqueValidator
This commit is contained in:
parent
6f78d5dc0a
commit
e85a1ac0f6
|
@ -11,6 +11,7 @@ from .models import (Dict, DictType, File, Dept, Permission, Post,
|
||||||
from rest_framework.exceptions import ParseError, APIException
|
from rest_framework.exceptions import ParseError, APIException
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from apps.third.tapis import dhapis
|
from apps.third.tapis import dhapis
|
||||||
|
from rest_framework.validators import UniqueValidator
|
||||||
|
|
||||||
class IntervalSerializer(CustomModelSerializer):
|
class IntervalSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -139,7 +140,10 @@ class RoleCreateUpdateSerializer(CustomModelSerializer):
|
||||||
"""
|
"""
|
||||||
角色序列化
|
角色序列化
|
||||||
"""
|
"""
|
||||||
|
name = serializers.CharField(label="名称", validators=[
|
||||||
|
UniqueValidator(queryset=Role.objects.all(), message='已存在相同名称的角色')])
|
||||||
|
code = serializers.CharField(label="标识", validators=[
|
||||||
|
UniqueValidator(queryset=Role.objects.all(), message='已存在相同标识的角色')])
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
exclude = EXCLUDE_FIELDS
|
exclude = EXCLUDE_FIELDS
|
||||||
|
|
Loading…
Reference in New Issue