Skip to content

Instantly share code, notes, and snippets.

View benjackson33's full-sized avatar

Ben J benjackson33

View GitHub Profile
@benjackson33
benjackson33 / djangoORM.md
Created December 5, 2023 07:06
Django ORM cheat sheet

Django ORM Cheat Sheet

Querying Data

Retrieving Objects

  • 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.