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.
711 sections in Django dev Search all versions →
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.
Topic guide Testing tools
Use the django.test.Client class to make requests. classClient(enforce_csrf_checks=False,raise_request_exception=True,json_encoder=DjangoJSONEncoder,*,headers=None,query_params=None,**defaults)[source] : A testing HTTP client. Takes several arguments that can customize behavior.
Topic guide Testing tools
Serialization is performed with [`DjangoJSONEncoder`](../serialization.md#django.core.serializers.json.DjangoJSONEncoder) by default, and can be overridden by providing a `json_encoder` argument to [`Client`](#django.test.Client). This serialization also happens for [`put()`](#django.test.Client.put), [`patch()`](#django.test.Client.patch), [`delete()`](#django.test.Client.delete), and [`query()`](#django.test.Client.query) requests. If you provide any other `content_type` (e.g.
Topic guide Testing tools
The `content_type` must match the data format, as [**RFC 10008**](https://datatracker.ietf.org/doc/html/rfc10008.md#section-2) requires servers to reject requests with a missing or inconsistent `Content-Type`. The `follow`, `secure`, `headers`, `query_params`, and `extra` parameters act the same as for [`Client.get()`](#django.test.Client.get).
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.
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 …
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 …
Topic guide Testing tools
SimpleTestCase.assertWarnsMessage(expected_warning,expected_message,callable,*args,**kwargs)[source] SimpleTestCase.assertWarnsMessage(expected_warning, expected_message) : Analogous to SimpleTestCase.assertRaisesMessage() but for assertWarnsRegex() instead of assertRaisesRegex(). SimpleTestCase.assertFieldOutput(fieldclass,valid,invalid,field_args=None,field_kwargs=None,empty_value='')[source] : Asserts that a form field behaves correctly with various inputs. SimpleTestCase.assertFormError(form,field,errors,msg_prefix='')[source] : Asserts that a field on a form raises the provided list of errors.
… backends.smtp.EmailBackend (class in django.core.mail) - BadRequest - bands (GDALRaster attribute) - base36_to_int() (in module django.utils.http) - base_field (ArrayField attribute) - (django.contrib.postgres.forms.BaseRangeField attribute) - (RangeField attribute) - (SimpleArrayField attribute) - (SplitArrayField attribute) - base_layer (BaseGeometryWidget attribute) - (OpenLayersWidget attribute) - (OSMWidget …
… - teardown_databases() (DiscoverRunner method) - (in module django.test.utils) - teardown_test_environment() (DiscoverRunner method) - (in module django.test.utils) - TelInput (class in django.forms) - tell() (HttpResponse method) - template - (Aggregate attribute) - Template (class in django.template) - template (Func attribute) - …
Reference Form fields
Each Field class constructor takes at least these arguments. Some Field classes take additional, field-specific arguments, but the following should always be accepted:
Reference Form fields
Field.widget The widget argument lets you specify a Widget class to use when rendering this Field. See Widgets for more information.
Reference Form fields
By default this value is set to "django/forms/field.html". Can be changed per field by overriding this attribute or more generally by overriding the default template, see also Overriding built-in field templates.
Reference Form fields
Reference Form fields
- Validates that the given value is either a datetime.date, datetime.datetime or string formatted in a particular date format. - Error message keys: required, invalid
Reference Form fields
- Validates that the given value is either a datetime.datetime, datetime.date or string formatted in a particular datetime format. - Error message keys: required, invalid
Reference Form fields
classDurationField(**kwargs)[source] : - Default widget: TextInput - Empty value: None - Normalizes to: A Python timedelta. - Validates that the given value is a string which can be converted into a timedelta. The value must be between datetime.timedelta.min and datetime.timedelta.max.
Reference Form fields
classGenericIPAddressField(**kwargs)[source] : A field containing either an IPv4 or an IPv6 address.
Reference Form fields
classMultipleChoiceField(**kwargs)[source] : - Default widget: SelectMultiple - Empty value: [] (an empty list) - Normalizes to: A list of strings. - Validates that every value in the given list of values exists in the list of choices.
Reference Form fields
- Validates that the given value is either a datetime.time or string formatted in a particular time format. - Error message keys: required, invalid