Django: How to Access Installed Third Party App's Model and Data

237 Views Asked by At

I have been using django-river(https://github.com/javrasya/django-river) application within my app (https://github.com/rupin/WorkflowEngine)

I have used the Django rest framework in my application and would like to get the data from the django-river tables. The name of the table is State.

My serializer is as follows

from river.models import State
from rest_framework import serializers

class StateSerializer(serializers.Serializer):

    class Meta:
        model = State
        fields = ['id', 'label']

Also, my API view is as follows

from rest_framework import generics
from workflowengine.riverserializers.StateSerializer import StateSerializer
from river.models import State

class StateList(generics.ListAPIView):  

    serializer_class = StateSerializer
    def get_queryset(self):
        return State.objects.all()  

Through the Admin console, I have added 11 states inside my state table, which I have checked with pgadmin.

When i access the API through the browser, I get 11 empty sections in my API ( no error, just the data is missing).

enter image description here

I cant seem to understand how the 11 data points presented in the API are empty. That it presented 11 elements, but no data, which is pretty weird.

1

There are 1 best solutions below

0
On BEST ANSWER

I think you need to use:

class StateSerializer(serializers.ModelSerializer):