【问题标题】:How to hide the value for the password field in Django Rest Framework API view [closed]如何在 Django Rest Framework API 视图中隐藏密码字段的值 [关闭]
【发布时间】:2021-04-17 20:57:01
【问题描述】:

click here for the image 在密码字段的附件图像中,我需要“****”而不是“pass”,是否有任何可用于 Serialzers 的密码小部件?

【问题讨论】:

    标签: python python-3.x django django-rest-framework


    【解决方案1】:

    只需在您的序列化器字段中使用样式 arg:

    class YourSerializer(serializers.ModelSerializer):
        password = serializers.CharField(
            style={'input_type': 'password'}
        )
        class Meta:
            # ....
    

    【讨论】:

      猜你喜欢
      • 2018-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 2018-09-22
      • 1970-01-01
      相关资源
      最近更新 更多