class QuerySet:
Class Method | as_manager |
Undocumented |
Method | aggregate |
Return a dictionary containing the calculations (aggregation) over the current queryset. |
Method | alias |
Return a query set with added aliases for extra data or aggregations. |
Method | all |
Return a new QuerySet that is a copy of the current one. This allows a QuerySet to proxy for a model manager in some cases. |
Method | annotate |
Return a query set in which the returned objects have been annotated with extra data or aggregations. |
Method | bulk_create |
No summary |
Method | bulk_update |
Update the given fields in each of the given objects in the database. |
Method | contains |
Return True if the queryset contains an object. |
Method | count |
Perform a SELECT COUNT() and return the number of records as an integer. |
Method | create |
Create a new object with the given kwargs, saving it to the database and returning the created object. |
Method | dates |
Return a list of date objects representing all available dates for the given field_name, scoped to 'kind'. |
Method | datetimes |
Return a list of datetime objects representing all available datetimes for the given field_name, scoped to 'kind'. |
Method | defer |
No summary |
Method | delete |
Delete the records in the current QuerySet. |
Method | difference |
Undocumented |
Method | distinct |
Return a new QuerySet instance that will select only distinct results. |
Method | earliest |
Undocumented |
Method | exclude |
Return a new QuerySet instance with NOT (args) ANDed to the existing set. |
Method | exists |
Undocumented |
Method | explain |
Undocumented |
Method | extra |
Add extra SQL fragments to the query. |
Method | filter |
Return a new QuerySet instance with the args ANDed to the existing set. |
Method | first |
Return the first object of a query or None if no match is found. |
Method | get |
Perform the query and return a single object matching the given keyword arguments. |
Method | get_or_create |
Look up an object with the given kwargs, creating one if necessary. Return a tuple of (object, created), where created is a boolean specifying whether an object was created. |
Method | in_bulk |
Return a dictionary mapping each of the given IDs to the object with that ID. If id_list isn't provided, evaluate the entire QuerySet. |
Method | intersection |
Undocumented |
Method | iterator |
An iterator over the results from applying this QuerySet to the database. |
Method | last |
Return the last object of a query or None if no match is found. |
Method | latest |
Undocumented |
Method | none |
Return an empty QuerySet. |
Method | only |
Essentially, the opposite of defer(). Only the fields passed into this method and that are not already specified as deferred are loaded immediately when the queryset is evaluated. |
Method | order_by |
Return a new QuerySet instance with the ordering changed. |
Method | prefetch_related |
Return a new QuerySet instance that will prefetch the specified Many-To-One and Many-To-Many related objects when the QuerySet is evaluated. |
Method | raw |
Undocumented |
Method | reverse |
Reverse the ordering of the QuerySet. |
Method | select_for_update |
Return a new QuerySet instance that will select objects with a FOR UPDATE lock. |
Method | select_related |
Return a new QuerySet instance that will select related objects. |
Method | union |
Undocumented |
Method | update |
Update all elements in the current QuerySet, setting all the given fields to the appropriate values. |
Method | update_or_create |
No summary |
Method | using |
Select which database this QuerySet should execute against. |
Method | values |
Undocumented |
Method | values_list |
Undocumented |
Static Method | _validate_values_are_expressions |
Undocumented |
Method | __and__ |
Undocumented |
Method | __bool__ |
Undocumented |
Method | __class_getitem__ |
Undocumented |
Method | __deepcopy__ |
Don't populate the QuerySet's cache. |
Method | __getitem__ |
Retrieve an item or slice from the set of results. |
Method | __getstate__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __iter__ |
No summary |
Method | __len__ |
Undocumented |
Method | __or__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | __setstate__ |
Undocumented |
Method | _add_hints |
Update hinting information for use by routers. Add new key/values or overwrite existing key/values. |
Method | _annotate |
Undocumented |
Method | _batched_insert |
Helper method for bulk_create() to insert objs one batch at a time. |
Method | _chain |
Return a copy of the current QuerySet that's ready for another operation. |
Method | _clone |
Return a copy of the current QuerySet. A lightweight alternative to deepcopy(). |
Method | _combinator_query |
Undocumented |
Method | _earliest |
Return the earliest object according to fields (if given) or by the model's Meta.get_latest_by. |
Method | _extract_model_params |
Prepare params for creating a model instance based on the given kwargs; for use by get_or_create(). |
Method | _fetch_all |
Undocumented |
Method | _filter_or_exclude |
Undocumented |
Method | _filter_or_exclude_inplace |
Undocumented |
Method | _has_filters |
Check if this QuerySet has any filtering going on. This isn't equivalent with checking if all objects are present in results, for example, qs[1:]._has_filters() -> False. |
Method | _insert |
Insert a new record for the given model. This provides an interface to the InsertQuery class and is how Model.save() is implemented. |
Method | _iterator |
Undocumented |
Method | _merge_known_related_objects |
Keep track of all known related objects from either QuerySet instance. |
Method | _merge_sanity_check |
Check that two QuerySet classes may be merged. |
Method | _next_is_sticky |
No summary |
Method | _not_support_combined_queries |
Undocumented |
Method | _prefetch_related_objects |
Undocumented |
Method | _prepare_for_bulk_create |
Undocumented |
Method | _raw_delete |
Delete objects found from the given queryset in single direct SQL query. No signals are sent and there is no protection for cascades. |
Method | _update |
No summary |
Method | _values |
Undocumented |
Method | complex_filter |
Return a new QuerySet instance with filter_obj added to the filters. |
Method | query.setter |
Undocumented |
Method | resolve_expression |
Undocumented |
Instance Variable | _db |
Undocumented |
Instance Variable | _defer_next_filter |
Undocumented |
Instance Variable | _deferred_filter |
Undocumented |
Instance Variable | _fields |
Undocumented |
Instance Variable | _for_write |
Undocumented |
Instance Variable | _hints |
Undocumented |
Instance Variable | _iterable_class |
Undocumented |
Instance Variable | _known_related_objects |
Undocumented |
Instance Variable | _prefetch_done |
Undocumented |
Instance Variable | _prefetch_related_lookups |
Undocumented |
Instance Variable | _query |
Undocumented |
Instance Variable | _result_cache |
Undocumented |
Instance Variable | _sticky_filter |
Undocumented |
Instance Variable | model |
Undocumented |
Property | db |
Return the database used if this query is executed now. |
Property | ordered |
Return True if the QuerySet is ordered -- i.e. has an order_by() clause or a default ordering on the model (or is empty). |
Property | query |
Undocumented |
Return a dictionary containing the calculations (aggregation) over the current queryset.
If args is present the expression is passed as a kwarg using the Aggregate object's default alias.
Perform a SELECT COUNT() and return the number of records as an integer.
If the QuerySet is already fully cached, return the length of the cached results set to avoid multiple SELECT COUNT(*) calls.
id_list
isn't provided, evaluate the entire QuerySet.Return a new QuerySet instance that will prefetch the specified Many-To-One and Many-To-Many related objects when the QuerySet is evaluated.
When prefetch_related() is called more than once, append to the list of prefetch lookups. If prefetch_related(None) is called, clear the list.
Return a new QuerySet instance that will select related objects.
If fields are specified, they must be ForeignKey fields and only those related objects are included in the selection.
If select_related(None) is called, clear the list.
The queryset iterator protocol uses three nested iterators in the default case:
sql.compiler.execute_sql() - Returns 100 rows at time (constants.GET_ITERATOR_CHUNK_SIZE)
using cursor.fetchmany(). This part is responsible for doing some column masking, and returning the rows in chunks.
sql.compiler.results_iter() - Returns one row at time. At this point the rows are still just
tuples. In some cases the return values are converted to Python values at this location.
self.iterator() - Responsible for turning the rows into model objects.
params
for creating a model instance based on the given
kwargs; for use by get_or_create().Indicate that the next filter call and the one following that should be treated as a single filter. This is only important when it comes to determining when to reuse tables for many-to-many filters. Required so that we can filter naturally on the results of related managers.
This doesn't return a clone of the current QuerySet (it returns "self"). The method is only used internally and should be immediately followed by a filter() that does create a clone.
Return a new QuerySet instance with filter_obj added to the filters.
filter_obj can be a Q object or a dictionary of keyword lookup arguments.
This exists to support framework features such as 'limit_choices_to', and usually it will be more natural to use other methods.