Skip to content

Documentation: ORM-Less View Examples #777

@Rjak

Description

@Rjak

I am working on both a personal project and a project for work which retrieves data from external sources, not from an ORM.

My personal project has a class-based view like this:

class PeopleList(APIView):
    """Provides the list of people to choose when performing a person search."""
    def get(self, request, format=None):
        search_term = request.data['search_term']
        input_data = { 'search_term': search_term }
        input_serializer = SearchTermSerializer(data=input_data)
        if not input_serializer.is_valid():
            return Response(input_serializer.errors,
                            status=status.HTTP_400_BAD_REQUEST)

        dao = get_external_dao()
        result = dao.person_search(input_serializer)
        return Response(result.data)

When I enable DJA, I get the following response to this query:

{
    "errors": [
        {
            "detail": "Received document does not contain primary data",
            "status": "400",
            "source": {
                "pointer": "/data"
            },
            "code": "parse_error"
        }
    ]
}

It's not clear to me what this error message refers to. Is there a problem with the request body I am submitting? The search term is specified in a request body (I'm not using filtering here because my understanding is that filters are tied to querysets and since the data is coming from an external API and not an ORM it is not applicable).

The only examples I can find are bound to ORM usage, so I'm finding it tough to even examine the problem.

An example which shows custom logic for handling a string match search against an external, non-ORM data source would help me in this case.

Thanks very much!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions