from rest_framework import serializers
from .models import Article



class ArticleSerializer(serializers.ModelSerializer):
    class Meta:
        model=Article
        fields=['id', 'title','author','emai', 'date']



#class ArticleSerializer(serializers.Serializer):



        # title=serializers.CharField(max_length=100)
        # author=serializers.CharField(max_length=100)
        # emai=serializers.EmailField(max_length=100)
        # date=serializers.DateTimeField()

        # def create(self,validated_data):
        #     return Article.objects.create(validated_data)
        # def update(self, instance, validated_data):
        #     instance.title=validated_data.get('title', instance.title)
        #     instance.author=validated_data.get('author',instance.author)
        #     instance.emai=validated_data.get('emai'.instance.emai)
        #     instance.date=validated_data.get('date',instance.date)
        #     instance.save()
        #     return instance