Tutorial Writing your first Django app, part 7
OK, we have our Question admin page, but a Question has multiple Choices, and the admin page doesn’t display choices. Yet. There are two ways to solve this problem.
477 sections across all versions Narrow to Django 6.0 (current) →
Tutorial Writing your first Django app, part 7
OK, we have our Question admin page, but a Question has multiple Choices, and the admin page doesn’t display choices. Yet. There are two ways to solve this problem.
Tutorial Writing your first Django app, part 7
OK, we have our Question admin page, but a Question has multiple Choices, and the admin page doesn’t display choices. Yet. There are two ways to solve this problem.
Reference QuerySet API reference
distinct(*fields) Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results. By default, a QuerySet will not eliminate duplicate rows.
Reference QuerySet API reference QuerySet APIMethods that return new QuerySets
distinct(*fields) Returns a new QuerySet that uses SELECT DISTINCT in its SQL query. This eliminates duplicate rows from the query results. By default, a QuerySet will not eliminate duplicate rows.
Internals Django Deprecation Timeline
ALLOWED_INCLUDE_ROOTS TEMPLATE_CONTEXT_PROCESSORS TEMPLATE_DEBUG TEMPLATE_DIRS TEMPLATE_LOADERS TEMPLATE_STRING_IF_INVALID The backwards compatibility alias django.template.loader.BaseLoader will be removed. Django template objects returned by get_template() and select_template() won’t accept a Context in their render() method anymore.
Topic guide Making queries
When spanning a ManyToManyField or a reverse ForeignKey (such as from Blog to Entry), filtering on multiple attributes raises the question of whether to require each attribute to coincide in the same related object.
Topic guide Making queries Retrieving objectsLookups that span relationships
When spanning a ManyToManyField or a reverse ForeignKey (such as from Blog to Entry), filtering on multiple attributes raises the question of whether to require each attribute to coincide in the same related object.
Internals Django Deprecation Timeline
ALLOWED_INCLUDE_ROOTS TEMPLATE_CONTEXT_PROCESSORS TEMPLATE_DEBUG TEMPLATE_DIRS TEMPLATE_LOADERS TEMPLATE_STRING_IF_INVALID The backwards compatibility alias django.template.loader.BaseLoader will be removed. Django template objects returned by get_template() and select_template() won’t accept a Context in their render() method anymore.
Internals Django Deprecation Timeline
ALLOWED_INCLUDE_ROOTS TEMPLATE_CONTEXT_PROCESSORS TEMPLATE_DEBUG TEMPLATE_DIRS TEMPLATE_LOADERS TEMPLATE_STRING_IF_INVALID The backwards compatibility alias django.template.loader.BaseLoader will be removed. Django template objects returned by get_template() and select_template() won’t accept a Context in their render() method anymore.
Internals Django Deprecation Timeline
ALLOWED_INCLUDE_ROOTS TEMPLATE_CONTEXT_PROCESSORS TEMPLATE_DEBUG TEMPLATE_DIRS TEMPLATE_LOADERS TEMPLATE_STRING_IF_INVALID The backwards compatibility alias django.template.loader.BaseLoader will be removed. Django template objects returned by get_template() and select_template() won’t accept a Context in their render() method anymore.
Topic guide Search
PostgreSQL has its own full text search implementation built-in. While not as powerful as some other search engines, it has the advantage of being inside your database and so can easily be combined with other relational queries such as categorization.
Topic guide Search Use CasesDocument-based search
PostgreSQL has its own full text search implementation built-in. While not as powerful as some other search engines, it has the advantage of being inside your database and so can easily be combined with other relational queries such as categorization.
Reference QuerySet API reference
values(*fields,**expressions) Returns a QuerySet that returns dictionaries, rather than model instances, when used as an iterable. Each of those dictionaries represents an object, with the keys corresponding to the attribute names of model objects.
Reference QuerySet API reference
update(**kwargs) aupdate(**kwargs) Asynchronous version: aupdate() Performs an SQL update query for the specified fields, and returns the number of rows matched (which may not be equal to the number of rows updated if some rows already have the new value).
Topic guide Models
Each field takes a certain set of field-specific arguments (documented in the model field reference). For example, CharField (and its subclasses) require a max_length argument which specifies the size of the VARCHAR database field used to store the data.
Topic guide Models
To define a many-to-many relationship, use ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model. ManyToManyField requires a positional argument: the class to which the model is related.
Reference QuerySet API reference QuerySet APIMethods that return new QuerySets
values(*fields,**expressions) Returns a QuerySet that returns dictionaries, rather than model instances, when used as an iterable. Each of those dictionaries represents an object, with the keys corresponding to the attribute names of model objects.
Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets
update(**kwargs) aupdate(**kwargs) Asynchronous version: aupdate() Performs an SQL update query for the specified fields, and returns the number of rows matched (which may not be equal to the number of rows updated if some rows already have the new value).
Topic guide Models Fields
Each field takes a certain set of field-specific arguments (documented in the model field reference). For example, CharField (and its subclasses) require a max_length argument which specifies the size of the VARCHAR database field used to store the data.
Topic guide Models FieldsRelationships
To define a many-to-many relationship, use ManyToManyField. You use it just like any other Field type: by including it as a class attribute of your model. ManyToManyField requires a positional argument: the class to which the model is related.