djangodocs.org

238 sections in Django 4.2 Search all versions →

ModelAdmin options

Reference The Django admin site ModelAdmin objects

ModelAdmin.filter_horizontal : By default, a ManyToManyField is displayed in the admin site with a <select multiple>. However, multiple-select boxes can be difficult to use when selecting many items.

dbshell

Reference django-admin and manage.py Available commands

django-admin dbshell Runs the command-line client for the database engine specified in your ENGINE setting, with the connection parameters specified in your USER, PASSWORD, etc., settings. For PostgreSQL, this runs the psql command-line client.

shell

Reference django-admin and manage.py Available commands

django-admin shell Starts the Python interactive interpreter. --interface {ipython,bpython,python}, -i {ipython,bpython,python} Specifies the shell to use. By default, Django will use IPython or bpython if either is installed.

Forms

Reference

Detailed form API reference. For introductory material, see the Working with forms topic guide.

MultiWidget

Reference Widgets Base widget classes

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

Reference QuerySet API reference

Internally, a QuerySet can be constructed, filtered, sliced, and generally passed around without actually hitting the database. No database activity actually occurs until you do something to evaluate the queryset. You can evaluate a QuerySet in the following ways: Iteration.

explain()

Reference QuerySet API reference QuerySet APIMethods that do not return QuerySets

explain(format=None,**options) aexplain(format=None,**options) Asynchronous version: aexplain() Returns a string of the QuerySet’s execution plan, which details how the database would execute the query, including any indexes or joins that would be used.

Topic guide Django’s cache framework

If you’re after even more control, you can also cache template fragments using the cache template tag. To give your template access to this tag, put {% load cache %} near the top of your template.

Topic guide Aggregation Aggregations and other QuerySet clausesvalues()

Fields that are mentioned in the order_by() part of a queryset are used when selecting the output data, even if they are not otherwise specified in the values() call.

Topic guide Making queries

Keyword argument queries – in filter(), etc. – are “AND”ed together. If you need to execute more complex queries (for example, queries with OR statements), you can use Q objects.

Topic guide Translation Internationalization: in template code

Contrarily to the translate tag, the blocktranslate tag allows you to mark complex sentences consisting of literals and variable content for translation by making use of placeholders: To translate a template expression – say, accessing object attributes or using template …

Topic guide How to install Django

If you plan to use Django’s database API functionality, you’ll need to make sure a database server is running. Django supports many different database servers and is officially supported with PostgreSQL, MariaDB, MySQL, Oracle and SQLite.

Tagging tests

Topic guide Testing tools Test cases features

You can tag your tests so you can easily run a particular subset.

Release notes Django 1.4 release notes What’s new in Django 1.4

Django 1.4 includes a QuerySet.select_for_update() method, which generates a SELECT ... FOR UPDATE SQL query. This will lock rows until the end of the transaction, meaning other transactions cannot modify or delete rows matched by a FOR UPDATE query.

Release notes Django 1.6.3 release notes

Historically, queries that use select_for_update() could be executed in autocommit mode, outside of a transaction. Before Django 1.6, Django’s automatic transactions mode allowed this to be used to lock records until the next write operation.

Release notes Django 1.7 release notes Backwards incompatible changes in 1.7

Historically, queries that use select_for_update() could be executed in autocommit mode, outside of a transaction. Before Django 1.6, Django’s automatic transactions mode allowed this to be used to lock records until the next write operation.

Bugfixes

Release notes Django 1.10.1 release notes

Fixed a crash in MySQL connections where SELECT @@SQL_AUTO_IS_NULL doesn’t return a result (#26991). Allowed User.is_authenticated and User.is_anonymous properties to be compared using ==, !=, and | (#26988, #27154). Removed the broken BaseCommand.usage() method which was for optparse support (#27000).

Bugfixes

Release notes Django 1.10.2 release notes

Fixed a crash in MySQL database validation where SELECT @@sql_mode doesn’t return a result (#27180). Allowed combining contrib.postgres.search.SearchQuery with more than one & or | operators (#27143). Disabled system check for URL patterns beginning with a ‘/’ when APPEND_SLASH=False (#27238).