djangodocs.org

728 sections in Django 5.2 Search all versions →

create()

Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets

create(**kwargs) acreate(**kwargs) Asynchronous version: acreate() A convenience method for creating an object and saving it all in one step. Thus: and: are equivalent.

bulk_create()

Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets

bulk_create(objs,batch_size=None,ignore_conflicts=False,update_conflicts=False,update_fields=None,unique_fields=None) abulk_create(objs,batch_size=None,ignore_conflicts=False,update_conflicts=False,update_fields=None,unique_fields=None) Asynchronous version: abulk_create() This method inserts the provided list of objects into the database in an efficient manner (generally only 1 query, no matter how many objects there are), and returns created objects as a list, in the …

With server-side cursors

Reference QuerySet API reference QuerySet APIMethods that do not return QuerySetsiterator()

Oracle and PostgreSQL use server-side cursors to stream results from the database without loading the entire result set into memory. The Oracle database driver always uses server-side cursors.

exact

Reference QuerySet API reference QuerySet APIField lookups

Exact match. If the value provided for comparison is None, it will be interpreted as an SQL NULL (see isnull for more details).

iexact

Reference QuerySet API reference QuerySet APIField lookups

Case-insensitive exact match. If the value provided for comparison is None, it will be interpreted as an SQL NULL (see isnull for more details). Example: SQL equivalents: Note the first query will match 'Beatles Blog', 'beatles blog', 'BeAtLes BLoG', etc.

contains

Reference QuerySet API reference QuerySet APIField lookups

Case-sensitive containment test. Example: SQL equivalent: Note this will match the headline 'Lennon honored today' but not 'lennon honored today'. NOTE: SQLite doesn’t support case-sensitive LIKE statements; contains > acts like icontains for SQLite.

icontains

Reference QuerySet API reference QuerySet APIField lookups

Case-insensitive containment test. Example: SQL equivalent: NOTE: When using the SQLite backend and non-ASCII strings, bear in mind the > database note about string comparisons.

startswith

Reference QuerySet API reference QuerySet APIField lookups

Case-sensitive starts-with. Example: SQL equivalent: SQLite doesn’t support case-sensitive LIKE statements; startswith acts like istartswith for SQLite.

istartswith

Reference QuerySet API reference QuerySet APIField lookups

Case-insensitive starts-with. Example: SQL equivalent: NOTE: When using the SQLite backend and non-ASCII strings, bear in mind the > database note about string comparisons.

endswith

Reference QuerySet API reference QuerySet APIField lookups

Case-sensitive ends-with. Example: SQL equivalent: NOTE: SQLite doesn’t support case-sensitive LIKE statements; endswith > acts like iendswith for SQLite. Refer to the database note documentation for more.

iendswith

Reference QuerySet API reference QuerySet APIField lookups

Case-insensitive ends-with. Example: SQL equivalent: NOTE: When using the SQLite backend and non-ASCII strings, bear in mind the > database note about string comparisons.

range

Reference QuerySet API reference QuerySet APIField lookups

Range test (inclusive). Example: SQL equivalent: You can use range anywhere you can use BETWEEN in SQL — for dates, numbers and even characters.

date

Reference QuerySet API reference QuerySet APIField lookups

For datetime fields, casts the value as date. Allows chaining additional field lookups. Takes a date value.

year

Reference QuerySet API reference QuerySet APIField lookups

For date and datetime fields, an exact year match. Allows chaining additional field lookups. Takes an integer year.

iso_year

Reference QuerySet API reference QuerySet APIField lookups

For date and datetime fields, an exact ISO 8601 week-numbering year match. Allows chaining additional field lookups. Takes an integer year.

month

Reference QuerySet API reference QuerySet APIField lookups

For date and datetime fields, an exact month match. Allows chaining additional field lookups. Takes an integer 1 (January) through 12 (December).