Quantcast
Channel: Django Rest Framework return empty JSON - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Django Rest Framework return empty JSON

$
0
0

I just start to implement Django Rest Framework by following several tutorials, however I can't fix my issue.

Actually, my API return empty JSON string :

[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]

This my code :

from rest_framework import serializersfrom wall.models import Articles

serializer.py

class ArticlesSerializer(serializers.Serializer):    class Meta:        model = Articles        fields = ('title',)

views.py

class ArticlesView(generics.ListAPIView):    queryset = Articles.objects.all()    serializer_class = ArticlesSerializer

urls.py

url('articles/', ArticlesView.as_view(), name="api-articles"),

models.py

class Articles(models.Model):    title = models.CharField(max_length=100, null=False, verbose_name="Titre")

I have many articles, so the JSON is returning as many article as I have in my database, but nothing else is displayed. Why ?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images