+1 vote
in Data Handling by
How to view and filter items from the database?

1 Answer

0 votes
by

In order to view all the items from your database, you can make use of the ‘all()’ function in your interactive shell as follows:

XYZ.objects.all()     where XYZ is some class that you have created in your models

To filter out some element from your database, you either use the get() method or the filter method as follows:

Programming & Frameworks Training

XYZ.objects.filter(pk=1)

XYZ.objects.get(id=1)

Related questions

+1 vote
asked Apr 4, 2020 in Data Handling by amita rallin
+1 vote
asked Apr 4, 2020 in Data Handling by amita rallin
...