25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

15 lines
527 B

  1. from api import models
  2. from rest_framework import serializers
  3. class PasswordSerializer(serializers.ModelSerializer):
  4. class Meta:
  5. model = models.Password
  6. fields = ('id', 'login', 'site', 'lowercase', 'uppercase', 'symbols', 'numbers', 'counter', 'length',
  7. 'created', 'modified')
  8. read_only_fields = ('created', 'modified')
  9. def create(self, validated_data):
  10. user = self.context['request'].user
  11. return models.Password.objects.create(user=user, **validated_data)