Django QuerySet Get Data

Django QuerySet Get Data

Get Data

There are different methods to get data from a model into a QuerySet.


The values() Method

The values() method allows you to return each object as a Python dictionary, with the names and values as key/value pairs:

View

members/views.py:

Run Example »


Return Specific Columns

The values_list() method allows you to return only the columns that you specify.

View

members/views.py:

Run Example »


Return Specific Rows

You can filter the search to only return specific rows/records, by using the filter() method.

View

members/views.py:

Run Example »

You will learn more about the filter() method in the next chapter.

ArmenianEnglish