Hi try debugging it by printing data, where this error is occuring and then 
you will be able to correct it.

Cheers


On Saturday, 11 May 2019 18:05:24 UTC+5:30, Arun Kumar Singamasetty wrote:
>
>
> ######from file serilaizers.py###############
>
>
> from rest_framework import serializers
> from .models import Article
>
> # class ArticleSerializer(serializers.Serializer):
> #     title = serializers.CharField(max_length=120)
> #     description = serializers.CharField()
> #     body = serializers.CharField()
> #     author_id = serializers.IntegerField()
>
> class ArticleSerializer(serializers.ModelSerializer):
>     class Meta:
>         model = Article
>         fields = ('title', 'description', 'body', 'author_id')
>
>     def create(self, validated_data):
>         return Article.objects.create(**validated_data)
>
> # class UserSerializer(serializers.HyperlinkedModelSerializer):
>
>
>
>
>
>
> #########from file models.py##############
>
>
> # from django.db import models
>
> # Create your models here.
> from django.db import models
>
> class Author(models.Model):
>   name = models.CharField(max_length=255)
>   email = models.EmailField()
>
>
> class Article(models.Model):
>     title = models.CharField(max_length=120)
>     description = models.TextField()
>     body = models.TextField()
>     author = models.ForeignKey('Author',on_delete=models.CASCADE,)
>
>     def __str__(self):
>         return self.title
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/338e8209-1808-4121-85be-c9fbfe4886bc%40googlegroups.com.

Reply via email to