djangodjango-models

How to extract Data from Django Queryset


How to retrieve the data from Django queryset for use in a variable

When an output is received in below form after running the query

<QuerySet [{'name': 'John'}]>

I want to use the value 'John' in a variable for further processing.

How do I extract this ?


Solution

  • k = <QuerySet [{'name': 'John'}]>
    k[0] = {'name': 'John'}
    

    Queryset is a list.