Internals
Django Deprecation Timeline
See the Django 1.5 release notes for more details on these changes. The module django.utils.simplejson will be removed. The standard library provides json which should be used instead. The function django.utils.itercompat.product will be removed.
Internals
The Django source code repository
Tags
queryset-refactor: A refactoring of the internals of Django’s object-relational mapper. This became part of Django as of the 1.0 release. unicode: A refactoring of Django’s internals to consistently use Unicode-based strings in most places within Django and Django applications.
Internals
Django’s security policies
Reporting security issuesReporting guidelines
Reports based on a failure to sanitize user input are not valid security vulnerabilities. It is the developer’s responsibility to properly handle user input. This principle is explained in our security documentation.
Reference
Applications
Initialization process
For example, a common mistake is making a database query to populate form field choices: In the example above, the query from Country.objects.all() is executed during module import, because the QuerySet is iterated over.
Reference
Class-based generic views - flattened index
Date-based views
… accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] 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_date_list() get_dated_items() get_dated_queryset() get_paginator() head() http_method_not_allowed() paginate_queryset() …
Reference
Class-based generic views - flattened index
Date-based views
classYearArchiveView Attributes (with optional accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] extra_context http_method_names make_object_list [get_make_object_list()] 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 year [get_year()] year_format [get_year_format()] Methods
Reference
Class-based generic views - flattened index
Date-based views
… Attributes (with optional accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] 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 year [get_year()] year_format [get_year_format()] Methods
Reference
Class-based generic views - flattened index
Date-based views
… Attributes (with optional accessor): allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] 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 week [get_week()] week_format [get_week_format()] year [get_year()] year_format [get_year_format()] Methods
Reference
Class-based generic views - flattened index
Date-based views
… allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] day [get_day()] day_format [get_day_format()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] 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 year [get_year()] year_format [get_year_format()] Methods
Reference
Class-based generic views - flattened index
Date-based views
… allow_empty [get_allow_empty()] allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] day [get_day()] day_format [get_day_format()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] 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 year [get_year()] year_format [get_year_format()] Methods
Reference
Class-based generic views - flattened index
Date-based views
… (with optional accessor): allow_future [get_allow_future()] content_type context_object_name [get_context_object_name()] date_field [get_date_field()] day [get_day()] day_format [get_day_format()] extra_context http_method_names model month [get_month()] month_format [get_month_format()] 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 year [get_year()] year_format [get_year_format()] Methods
Reference
Generic date views
classWeekArchiveView[source] : A weekly archive page showing all objects in a given week. Objects with a date in the future are not displayed unless you set allow_future to True.
Reference
Generic date views
classDayArchiveView[source] : A day archive page showing all objects in a given day. Days in the future throw a 404 error, regardless of whether any objects exist for future days, unless you set allow_future to True.
Reference
Date-based mixins
classBaseDateListView[source] : A base class that provides common behavior for all date-based views. There won’t normally be a reason to instantiate BaseDateListView; instantiate one of the subclasses instead.
Reference
Multiple object mixins
classdjango.views.generic.list.MultipleObjectMixin : A mixin that can be used to display a list of objects.
Reference
The Django admin site
ModelAdmin objects
The ModelAdmin is very flexible. It has several options for dealing with customizing the interface. All options are defined on the ModelAdmin subclass: ModelAdmin.actions : A list of actions to make available on the change list page.
Reference
The Django admin site
ModelAdmin objects
ModelAdmin.list_editable : Set list_editable to a list of field names on the model which will allow editing on the change list page.
Reference
The Django admin site
ModelAdmin objects
ModelAdmin.radio_fields : By default, Django’s admin uses a select-box interface (<select>) for fields that are ForeignKey or have choices set. If a field is present in radio_fields, Django will use a radio-button interface instead.
Reference
The Django admin site
ModelAdmin objects
Call super().delete_model() to delete the object using Model.delete(). ModelAdmin.delete_queryset(request,queryset)[source] : The delete_queryset() method is given the HttpRequest and a QuerySet of objects to be deleted. Override this method to customize the deletion process for the “delete selected objects” action.
Reference
The Django admin site
ModelAdmin objects
ModelAdmin.get_form(request,obj=None,**kwargs)[source] : Returns a ModelForm class for use in the admin add and change views, see add_view() and change_view(). ModelAdmin.get_formsets_with_inlines(request,obj=None)[source] : Yields (FormSet, InlineModelAdmin) pairs for use in admin add and change views.