@@ -0,0 +1,1233 @@
+__author__ = 'prism'%0Afrom django.contrib.auth import update_session_auth_hash%0Afrom rest_framework import serializers%0Afrom .models import Account%0A%0A%0Aclass AccountSerializer(serializers.ModelSerializer):%0A    password = serializers.CharField(write_only=True, required=False)%0A    confirm_password = serializers.CharField(write_only=True, required=False)%0A%0A    class Meta:%0A        model = Account%0A        fields = ('id', 'username', 'created_at', 'updated_at'%0A                  , 'password', 'confirm_password')%0A        read_only_fields = ('created_at', 'updated_at')%0A%0A        def create(self, validate_data):%0A            return Account.objects.create(**validate_data)%0A%0A        def update(self, instance, validated_data):%0A            instance.username = validated_data.get('username', instance.username)%0A%0A            instance.save()%0A%0A            password = validated_data.get('password', None)%0A            confirm_password = validated_data.get('confirm_password', None)%0A%0A            if password and confirm_password and password == confirm_password:%0A                instance.set_password(password)%0A                instance.save()%0A%0A            update_session_auth_hash(self.context.get('request'), instance)%0A%0A            return instance%0A    

Add serializer