from django.contrib.auth.hashers import make_password
from rest_framework import serializers

from api.models import User


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ("id", "username", "password")

    def create(self, validated_data):
        validated_data["password"] = <PASSWORD>_password(validated_data["password"])
        return User.objects.create(**validated_data)

from django.contrib.auth.hashers import make_password
from rest_framework import serializers

from api.models import User


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ("id", "username", "password")

    def create(self, validated_data):
        validated_data["password"] = <PASSWORD>_password(validated_data["password"])
        return User.objects.create(**validated_data)
