Methods that return new QuerySets
1) all() - This method is used to retrieve all objects(rows).
Example: Student.objects.all()
Here Student is the name of model name
2) filter() - This method is used to fetch specific data from database table
Example: Student.objects.filter(id=5)
It returns the object(row) of id =5
3) exclude() - This method is used to fetch the data that do not match the given lookup parameters
Example: Student.objects.exclude(id=5)
It returns the object(row) that does not match the id=5 i.e. id!=5
4) order_by(column_name) - It orders the field.
column_name = Asc order
-column_name = Desc order
? = Randomly
Example: Student.objects.order_by(id)
It returns the row by ascending order.
5) values(column_name) - It fetch the specific column from db table.
Example: Student.objects.values('name','city')
6) distinct(column_name) - This eliminates the duplicate rows from the query results.
Example: Student.objects.distinct('name')
0 Comments
Comment Rules :
1. Do not post Adult/illegal Links.
2. Try to comment in only मराठी / English Language.
3. Do not post other website's links which are useless.
4. Your Comment should be based on the Topic for other queries.
5. Do not use Abusive Language.
6. Respect each other.
Thank You for following the rules. Please Comment....