djangodocs.org

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

Topic guide Making queries Querying JSONField

… based on a given dictionary key, use that key as the lookup name: Multiple keys can be chained together to form a path lookup: If the key is an integer, it will be interpreted as an index transform in an …

4.2 5.0 5.1 5.2

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.

5.0 5.1 5.2 6.0

Arguments

Reference Model field reference Relationship fieldsManyToManyField

ForeignKey.related_name : The name to use for the relation from the related object back to this one. It’s also the default value for related_query_name (the name to use for the reverse filter name from the target model).

4.2 5.0 5.1

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()).

1.9

Internals Django Deprecation Timeline

The model and form IPAddressField will be removed. A stub field will remain for compatibility with historical migrations. AppCommand.handle_app() will no longer be supported. RequestSite and get_current_site() will no longer be importable from django.contrib.sites.models.

4.2 5.0 5.1 5.2 dev

O

Index

… opclasses (Index attribute) - (UniqueConstraint attribute) - open() (FieldFile method) - (File method) - (Storage method) - OpenLayersWidget (class in django.contrib.gis.forms.widgets) - OperationalError - OperationCategory (class in django.db.migrations.operations.base) - optimizemigration - django-admin command - optimizemigration command line option - --check …

Nonce config

How-to How to use Django’s Content Security Policy

To use nonces in your CSP policy, beside the basic config, you need to: Include the NONCE placeholder value in the CSP settings. This only applies to script-src or style-src directives: Add the csp() context processor to your TEMPLATES setting.

dev

5.0

Internals Django Deprecation Timeline

The undocumented BaseForm._html_output() method will be removed. The ability to return a str, rather than a SafeString, when rendering an ErrorDict and ErrorList will be removed. See the Django 4.1 release notes for more details on these changes.

dev

1.9

Internals Django Deprecation Timeline

The model and form IPAddressField will be removed. A stub field will remain for compatibility with historical migrations. AppCommand.handle_app() will no longer be supported. RequestSite and get_current_site() will no longer be importable from django.contrib.sites.models.

4.2 5.0 5.1 6.0 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.

Troubleshooting

Reference Applications Initialization process

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.

5.0 5.1 5.2 6.0 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 objects

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. AdminSite.password_change_form : > New in Django 6.0.

Reference GEOS API Geometry ObjectsGEOSGeometry

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.

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.