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 had [u'last_name', u'first_name',
u'agent',...] in result
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
Update
After debugging, I have found that the data is returning without the name of the model as a key. How do I return the data in the required format?