Tuesday, 19 February 2019

Django Rest Models ImproperlyConfigured:

I'm trying to use Django ORM where it queries an API rather than a database. I found the library Django Rest Models which does this in conjunction with the library dynamic-rest.

My model is called Client, and when I run:

Client.objects.filter(id=62)

I'm getting the following error:

ImproperlyConfigured: the response does not contains the result for client.  
maybe the resource name does not match the one on the api. please check if 
Client.APIMeta.resource_name_plural is ok

Can anyone help me understand how to fix this error?

Additional Info

This is my model on the client

class Client(models.Model):
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    agent = models.ForeignKey(Agent, db_column='agent')
    .....


    class APIMeta:
        resource_path = 'clients'
        resource_name = 'client'
        resource_name_plural = 'clients'
        pass

This is my code on the API

class ClientSerializer(DynamicModelSerializer):
    agent = DynamicRelationField('AgentSerializer')
    class Meta:
        fields = '__all__'
        model = Client
        name = 'client'


class AgentSerializer(DynamicModelSerializer):

    client = DynamicRelationField('ClientSerializer', many=True)

    class Meta:
        fields = '__all__'
        model = Agent



from Django Rest Models ImproperlyConfigured:

No comments:

Post a Comment