djangodocs.org

1305 sections across all versions Narrow to Django 6.0 (current) →

1.7

Internals Django Deprecation Timeline

The undocumented check_for_test_cookie method in AuthenticationForm will be removed following an accelerated deprecation. Users subclassing this form should remove calls to this method, and instead ensure that their auth related views are CSRF protected, which ensures that cookies are enabled.

dev

1.6

Internals Django Deprecation Timeline

They will be removed. The form wizard has been refactored to use class-based views with pluggable backends in 1.4. The previous implementation will be removed. Legacy ways of calling cache_page() will be removed.

dev

Namespacing URL names

Tutorial Writing your first Django app, part 3

… application namespace: polls/urls.py Now change your polls/index.html template from: polls/templates/polls/index.html to point at the namespaced detail view: polls/templates/polls/index.html When you’re comfortable with writing views, read part 4 of this tutorial to learn the basics about form processing and generic views.

dev

Troubleshooting

Reference Applications

This concept is known as “lazy evaluation”. django.contrib.admin automatically performs autodiscovery of admin modules in installed applications. To prevent it, change your INSTALLED_APPS to contain 'django.contrib.admin.apps.SimpleAdminConfig' instead of 'django.contrib.admin'. RuntimeWarning: Accessing the database during app initialization is discouraged.

dev

admin

Reference System check framework contrib app checks

Admin checks are all performed as part of the admin tag. The following checks are performed on any ModelAdmin (or subclass) that is registered with the admin site: admin.E001: The value of raw_id_fields must be a list or tuple.

AdminSite attributes

Reference The Django admin site

AdminSite.login_form : Subclass of AuthenticationForm that will be used by the admin site login view. AdminSite.logout_template : Path to a custom template that will be used by the admin site logout view.

dev

Reference django.contrib.auth

`user_can_authenticate()`[[source]](https://github.com/django/django/blob/main/django/contrib/auth/backends.py#L98) : Returns whether the user is allowed to authenticate. To match the behavior of [`AuthenticationForm.confirm_login_allowed()`](../../topics/auth/default.md#django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed), this method returns `False` for users with [`is_active=False`](#django.contrib.auth.models.User.is_active). Custom user models that don’t have an [`is_active`](../../topics/auth/customizing.md#django.contrib.auth.models.CustomUser.is_active) field are allowed.

dev

Reference GEOS API

PreparedGeometry objects are optimized for the contains, intersects, covers, crosses, disjoint, overlaps, touches and within operations. Refer to the Prepared Geometries documentation for more information. GEOSGeometry.srs : Returns a SpatialReference object corresponding to the SRID of the geometry or None.

dev

Nonce usage

Reference Content Security Policy

A CSP nonce (“number used once”) is a unique, random value generated per HTTP response. Django supports nonces as a secure way to allow specific inline <script> or <style> elements to execute without relying on 'unsafe-inline'.

dev

dumpdata

Reference django-admin and manage.py Available commands

--format FORMAT Specifies the serialization format of the output. Defaults to JSON. Supported formats are listed in Serialization formats. --indent INDENT Specifies the number of indentation spaces to use in the output.

MultiWidget

Reference Widgets

classMultiWidget(widgets,attrs=None)[source] : A widget that is composed of multiple widgets. MultiWidget works hand in hand with the MultiValueField.

dev

DateField

Reference Model field reference

If you want to be able to modify this field, set the following instead of auto_now_add=True: The default form widget for this field is a DateInput. The admin adds a JavaScript calendar, and a shortcut for “Today”.

dev

Field API reference

Reference Model field reference

classField[source] : Field is an abstract class that represents a database table column. Django uses fields to create the database table (db_type()), to map Python types to database (get_prep_value()) and vice-versa (from_db_value()).

dev

extra()

Reference QuerySet API reference

where / tables You can define explicit SQL WHERE clauses — perhaps to perform non-explicit joins — by using where. You can manually add tables to the SQL FROM clause by using tables.

dev

Using class-based views

Topic guide Introduction to class-based views

… is worth noting that what your method returns is identical to what you return from a function-based view, namely some form of HttpResponse. This means that http shortcuts or TemplateResponse objects are valid to use inside a class-based view. While …

dev