djangodocs.org

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

Topic guide Models

It doesn’t matter which model has the ManyToManyField, but you should only put it in one of the models – not both. Generally, ManyToManyField instances should go in the object that’s going to be edited on a form.

dev

Topic guide Time zones

Most websites that care about time zones ask users in which time zone they live and store this information in the user’s profile. For anonymous users, they use the time zone of their primary audience or UTC.

dev

Topic guide Translation

… within the translation block. Examples: You can use multiple expressions inside a single blocktranslate tag: NOTE: The previous more verbose format is still supported: > {% blocktranslate with book|title as book_t and author|title as author_t %} Other block tags (for …

dev

Message files

Topic guide Translation

NOTE: If you’re using Windows and need to install the GNU gettext utilities so > makemessages works, see gettext on Windows for more > information.

dev

TestCase

Topic guide Testing tools

classTestCase[source] This is the most common class to use for writing tests in Django. It inherits from TransactionTestCase (and by extension SimpleTestCase). If your Django application doesn’t use a database, use SimpleTestCase.

dev

LiveServerTestCase

Topic guide Testing tools

… time. In particular, this means that in some cases > (for example, just after clicking a link or submitting a form), you might > need to check that a response is received by Selenium and that the next > page …

dev

Overriding settings

Topic guide Testing tools

… | | --- | --- | | USE_TZ, TIME_ZONE | Databases timezone | | TEMPLATES | Template engines | | FORM_RENDERER | Default renderer | | SERIALIZATION_MODULES | Serializers cache | | LOCALE_PATHS, LANGUAGE_CODE | Default translation and loaded translations …

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.

6.0

1.10

Internals Django Deprecation Timeline

The following private APIs will be removed from django.db.models.options.Options (Model._meta): get_field_by_name() get_all_field_names() get_fields_with_model() get_concrete_fields_with_model() get_m2m_with_model() get_all_related_objects() get_all_related_objects_with_model() get_all_related_many_to_many_objects() get_all_related_m2m_objects_with_model() The error_message argument of django.forms.RegexField will be removed. The unordered_list filter will no longer support old style lists.

4.2 5.2 6.0

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

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.

4.2 5.0 5.1 5.2 6.0

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

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.

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

4.2 5.0 5.1 5.2 6.0

MultiWidget

Reference Widgets Base widget classes

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

4.2 5.0 5.1 5.2 6.0