vendredi 4 janvier 2019

Django REST API Listview

Currently I'm trying to develop personal blog with Django/REST API, and I have trouble for that.

There are a number of posts in blog and I want to control those posts with Hyperlink. I made it by using ModelViewSet, however, whole data in detailView is also shown in ListView.

The thing is, I only want "url" and "title" of posts to be shown in ListView while DetailView contains full data. Here is my code and current results given by REST framework.

# serializers

enter image description here

# views

enter image description here

# Post List in REST API

enter image description here

# Post instance in REST API

enter image description here




Aucun commentaire:

Enregistrer un commentaire