Skip to content
Advertisement

Tag: django-rest-framework

How to display questions based on subcategory using Django Rest Framework?

I want to display all questions based on subcategory. This is my code : models.py serializers.py view.py /api/subcategory : /api/questions : From the data above I have 2 subcategories Mathematics and History and have 3 questions based on the subcategory, 2 questions about mathematics and 1 question about history. How to display in /api/questions only 2 questions about Mathematics? I’m

SearchFilter for multiple models — Django

Using Django 3.2 with Restframework. I’m trying for search filter and create a API with restframework which would output the searched term with its whole object. I had a little success on that with official doc. But from that I can only search in a single Model and not as globally. I found a blog on how to use multiple

Object of type BoundField is not JSON serializable

A have a chain of OneToMany relations (one) Construction -> Camera -> Frame -> Event models.py I want to output data about Camera in EventSerializer (GET method). I am using get_construction method I want to use ConstructionSerializer for Construction object ( <class ‘api_buildings.models.Construction’>) But I have an error Object of type BoundField is not JSON serializable How can I fix

url path is matching the wrong view in drf viewsets

Django beginner here, I have two similar endpoints as shown below, they differ in their url_path of the action decorator and the request parameters requester_id and approval id The problem both /workflow_approvals/{requester_id}/ and /workflow_approvals/{approval_id}/ are routing to the requester method view(the first below) my urls.py file looks like this Answer Django doesn’t have a way of differentiating /workflow_approvals/{requester_id}/ and /workflow_approvals/{approval_id}/,

TypeError at /api/questions/ ‘list’ object is not callable

When I go to this http://127.0.0.1:8000/api/questions/ I get TypeError at /api/questions/ ‘list’ object is not callable urls.py (in project) urls.py (in appName1/api views.py (in appName1/api) Only showing QuestionViewSet From the settings.py Error could come from somewhere else. I don’t know where I can find “list”. appName1 = questions Exception Location: lib/python3.9/site-packages/rest_framework/generics.py, line 162, in paginator Answer The DEFAULT_PAGINATION_CLASS setting should

Advertisement