Internals
Django Deprecation Timeline
The Prefetch.get_current_queryset() method will be removed. The get_prefetch_queryset() method of related managers and descriptors will be removed. get_prefetcher() and prefetch_related_objects() will no longer fallback to get_prefetch_queryset(). The FORMS_URLFIELD_ASSUME_HTTPS transitional setting will be removed.
Internals
Django Deprecation Timeline
Support for pytz timezones will be removed. The is_dst argument will be removed from: QuerySet.datetimes() django.utils.timezone.make_aware() django.db.models.functions.Trunc() django.db.models.functions.TruncSecond() django.db.models.functions.TruncMinute() django.db.models.functions.TruncHour() django.db.models.functions.TruncDay() django.db.models.functions.TruncWeek() django.db.models.functions.TruncMonth() django.db.models.functions.TruncQuarter() django.db.models.functions.TruncYear() The django.contrib.gis.admin.GeoModelAdmin and OSMGeoAdmin classes will be removed. The undocumented BaseForm._html_output() method will be removed.
Internals
Django Deprecation Timeline
The default_app_config module variable will be removed. TransactionTestCase.assertQuerysetEqual() will no longer automatically call repr() on a queryset when compared to string values. django.core.cache.backends.memcached.MemcachedCache will be removed. Support for the pre-Django 3.2 format of messages used by django.contrib.messages.storage.cookie.CookieStorage will be removed.
Internals
Django Deprecation Timeline
Support for passing raw column aliases to QuerySet.order_by() will be removed. The model NullBooleanField will be removed. A stub field will remain for compatibility with historical migrations. django.conf.urls.url() will be removed. The model django.contrib.postgres.fields.JSONField will be removed.
Internals
Django Deprecation Timeline
The field_name keyword argument of QuerySet.earliest() and latest() will be removed. See the Django 2.1 release notes for more details on these changes. django.contrib.gis.db.models.functions.ForceRHR will be removed. django.utils.http.cookie_date() will be removed.
Internals
Django Deprecation Timeline
Remove the backward compatible shims introduced to rename get_query_set and similar queryset methods. This affects the following classes: BaseModelAdmin, ChangeList, BaseCommentNode, GenericForeignKey, Manager, SingleRelatedObjectDescriptor and ReverseSingleRelatedObjectDescriptor. Remove the backward compatible shims introduced to rename the attributes ChangeList.root_query_set and ChangeList.query_set.
Tutorial
Writing your first Django app, part 4
Use generic views: Less code is better
This is provided using either the model attribute (in this example, model = Question for DetailView and ResultsView) or by defining the get_queryset() method (as shown in IndexView).
Tutorial
Writing your first Django app, part 5
Test a view
Let’s fix that. In Tutorial 4 we introduced a class-based view, based on ListView: polls/views.py We need to amend the get_queryset() method and change it so that it also checks the date by comparing it with timezone.now().
Tutorial
Writing your first Django app, part 5
Test a view
What we have works well; however, even though future questions don’t appear in the index, users can still reach them if they know or guess the right URL.
Reference
Class-based generic views - flattened index
Detail Views
classDetailView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context http_method_names model pk_url_kwarg query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() get() get_context_data() get_object() head() http_method_not_allowed() render_to_response() setup()
Reference
Class-based generic views - flattened index
List Views
classListView Attributes (with optional accessor): allow_empty [get_allow_empty()] content_type context_object_name [get_context_object_name()] extra_context http_method_names model ordering [get_ordering()] paginate_by [get_paginate_by()] paginate_orphans [get_paginate_orphans()] paginator_class queryset [get_queryset()] response_class [render_to_response()] template_engine template_name [get_template_names()] template_name_suffix Methods as_view() dispatch() get() get_context_data() get_paginator() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference
Class-based generic views - flattened index
Editing views
classCreateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [get_prefix()] query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() form_invalid() form_valid() get() …
Reference
Class-based generic views - flattened index
Editing views
classUpdateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [get_prefix()] query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() form_invalid() form_valid() get() …
Reference
Class-based generic views - flattened index
Editing views
classDeleteView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context http_method_names model pk_url_kwarg query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() delete() dispatch() get() get_context_data() get_object() head() http_method_not_allowed() post() render_to_response() setup()
Reference
Class-based generic views - flattened index
Date-based views
Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_paginator() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference
Class-based generic views - flattened index
Date-based views
Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_next_month() get_paginator() get_previous_month() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference
Class-based generic views - flattened index
Date-based views
Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_paginator() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference
Class-based generic views - flattened index
Date-based views
Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_next_day() get_next_month() get_paginator() get_previous_day() get_previous_month() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference
Class-based generic views - flattened index
Date-based views
Methods as_view() dispatch() get() get_context_data() get_date_list() get_dated_items() get_dated_queryset() get_next_day() get_next_month() get_paginator() get_previous_day() get_previous_month() head() http_method_not_allowed() paginate_queryset() render_to_response() setup()
Reference
Generic date views
classArchiveIndexView[source] : A top-level index page showing the “latest” objects, by date. Objects with a date in the future are not included unless you set allow_future to True.