Skip to content
Proyectos

chrisdl/Django-QuerySet-Cheatsheet

Ver en GitHub

Acerca de

A cheatsheet (or really more of a reference) for when I am solving the worlds problems in the Django shell

Desarrollo web y de aplicaciones

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Actualización retrasada

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

Cheatsheet for Django QuerySets

Current Django Version: 5.2

Mandatory impostor syndrome notice: The documentation has gotten a lot easier to navigate and this cheatsheet makes a lot less sense nowadays, but many people seem to be actively using it, so i'll keep it updated for a few more versions.

Methods that return new QuerySets

Can be chained:

Entry.objects.filter(**kwargs).exclude(**kwargs).order_by(**kwargs)

Operators that return new QuerySets

Methods that do not return QuerySets

Field lookups (link)

**Field lookups are how you specify the meat of an SQL WHERE clause. They’re specified as keyword arguments to the QuerySet methods filter(), exclude() and get().**

Example: Entry.objects.get(id__exact=14)  # note double underscore.

Protip: Use in to avoid chaining filter() and exclude()

Entry.objects.filter(status__in=['Hung over', 'Sober', 'Drunk'])

Aggregation functions (link)

Query-related tools (link)


Creative Commons License
Django-QuerySet-Cheatsheet by @chrisdl and @briandant is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

The contributors are as gods among ants and shall forever be remembered as such.

The Django web framework referenced in the Django-QuerySet-Cheatsheet is ​© 2005-2025 Django Software Foundation. Django is a registered trademark of the Django Software Foundation.

Explorar proyectos relacionados

Cargando…