-4

AttributeError: module 'rest_framework.serializers' has no attribute 'PasswordInput'

serializer.py :

from rest_framework import serializers
from django.contrib.auth.models import User


class SampleSerializer(serializers.ModelSerializer):
    password2 = serializers.CharField(widget=serializers.PasswordInput())
    class Meta:
        model = User
        fields = ['username','email','password']
Harsh Nagarkar
  • 697
  • 7
  • 23
  • Welcome to SO! Please see "[ask]", "[Stack Overflow question checklist](https://meta.stackoverflow.com/questions/260648)" and "[MCVE](https://stackoverflow.com/help/minimal-reproducible-example)" and all their linked pages. – the Tin Man Apr 15 '20 at 05:54

1 Answers1

0

I think the error is self-explanatory. Your code should look like this.

password2 = serializers.CharField(write_only=True)

Read this StackOverflow post to answer your question in more depth how to mention password field in serializer?

Harsh Nagarkar
  • 697
  • 7
  • 23