Model.objects.all(): Retrieve all objects in the model.Model.objects.get(): Retrieve a single object that matches the query.Model.objects.filter(): Retrieve objects that match the specified lookup parameters.Model.objects.exclude(): Retrieve objects that do not match the specified lookup parameters.
filter().exclude(): Chain filters and exclusions together.filter().filter(): Chain multiple filters together.annotate(): Add annotations to the queryset.order_by(): Sort the queryset based on specified fields.values(): Return a QuerySet of dictionaries instead of model instances.distinct(): Return distinct results for a queryset.
exact,iexact: Exact match (case-sensitive, case-insensitive).contains,icontains: Case-sensitive, case-insensitive containment test.- ... (other field lookups)
Model.objects.create(): Create a new object and save it to the database.object.save(): Save changes to an existing object.
object.save(): Save changes to an existing object.Model.objects.update(): Update multiple objects at once.update_or_create(): Update an existing object or create a new one.
object.delete(): Delete a single object.Model.objects.filter().delete(): Delete multiple objects matching a filter.
aggregate(): Perform aggregate functions on a queryset (e.g.,Sum,Count,Avg).
- Access related objects through object attributes (
related_name,related_query_name). - Use double underscores for traversing relationships in queries (e.g.,
related_model__field).