A
A
alex n_lu2019-04-24 18:42:15
Django
alex n_lu, 2019-04-24 18:42:15

How to return QuerySet from View?

I have such a function for selecting several objects, which I call from ajax:

def get_elements(request):
    """View function for getting all existed elements (lines) of the scheme of the specific plan"""

    data = request.GET
    plan = get_object_or_404(Plan, pk=data.get("plan"))

    v = Element.objects.filter(plan=plan)

    return ...

v - this is a set of objects, not a single object
What should I write in return to return this set to my ajax? What I just did not write gives errors ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question