Answer the question
In order to leave comments, you need to log in
How to properly use json rpc in django?
Hello
I decided to get acquainted with django, I know only very superficial things.
In search of the ideal, I decided to develop an api using json-rpc. The django-modern-rpc library .
According to the documentation, I checked a couple of examples, everything is fine.
But as soon as I decided to make a selection from the database and return it, I got an error
{
"id": 1,
"jsonrpc": "2.0",
"error": {
"code": -32603,
"message": "Internal error: Unable to serialize result as valid JSON: Object of type QuerySet is not JSON serializable"
}
}
Answer the question
In order to leave comments, you need to log in
it is more convenient for your task to use Django Rest Framework. there, in particular, there is such a thing as serializers (which make simple Python data structures from dzhang models and QuerySets; this step, apparently, you have not completed), and typical things are implemented out of the box.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question