Beispiel #1
0
class UserCreateBody(serializers.ModelSerializer):
    role = serializers.ChoiceField(
        help_text=UserRole.get_info("User roles:", list_str=True),
        choices=UserRole.to_choices(string_as_value=True),
    )
    password = serializers.CharField(
        help_text="Password for new user", min_length=6, max_length=32
    )

    class Meta:
        model = UserModel
        fields = ("name", "role", "govern", "password")
        extra_kwargs = {
            "name": {"required": True},
            "role": {"required": True},
            "password": {"required": True},
        }
Beispiel #2
0
class UserCreateBody(serializers.ModelSerializer):
    role = serializers.ChoiceField(
        help_text=UserRole.get_info("User roles:", list_str=True),
        choices=UserRole.to_choices(string_as_value=True),
    )

    class Meta:
        model = UserProfile
        fields = ("username", "role", "organization", "password", "email")
        extra_kwargs = {
            "username": {
                "required": True
            },
            "role": {
                "required": True
            },
            "password": {
                "required": True
            },
            "email": {
                "required": True
            },
        }