diff --git a/README.md b/README.md index f875f65dd6..af89adbb8c 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Some reasons you might want to use REST framework: # Requirements * Python 3.10+ -* Django 4.2, 5.0, 5.1, 5.2, 6.0 +* Django 5.0, 5.1, 5.2, 6.0 We **highly recommend** and only officially support the latest patch release of each Python and Django series. diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index ca63192888..890d7c813e 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -330,7 +330,7 @@ Corresponds to `django.db.models.fields.DateTimeField`. * `format` - A string representing the output format. If not specified, this defaults to the same value as the `DATETIME_FORMAT` settings key, which will be `'iso-8601'` unless set. Setting to a format string indicates that `to_representation` return values should be coerced to string output. Format strings are described below. Setting this value to `None` indicates that Python `datetime` objects should be returned by `to_representation`. In this case the datetime encoding will be determined by the renderer. * `input_formats` - A list of strings representing the input formats which may be used to parse the date. If not specified, the `DATETIME_INPUT_FORMATS` setting will be used, which defaults to `['iso-8601']`. -* `default_timezone` - A `tzinfo` subclass (`zoneinfo` or `pytz`) representing the timezone. If not specified and the `USE_TZ` setting is enabled, this defaults to the [current timezone][django-current-timezone]. If `USE_TZ` is disabled, then datetime objects will be naive. +* `default_timezone` - A `tzinfo` subclass (`zoneinfo`) representing the timezone. If not specified and the `USE_TZ` setting is enabled, this defaults to the [current timezone][django-current-timezone]. If `USE_TZ` is disabled, then datetime objects will be naive. #### `DateTimeField` format strings. diff --git a/docs/index.md b/docs/index.md index 6efc1c19db..d2e2a9bf57 100644 --- a/docs/index.md +++ b/docs/index.md @@ -61,7 +61,7 @@ Some reasons you might want to use REST framework: REST framework requires the following: -* Django (4.2, 5.0, 5.1, 5.2) +* Django (5.0, 5.1, 5.2) * Python (3.10, 3.11, 3.12, 3.13, 3.14) We **highly recommend** and only officially support the latest patch release of diff --git a/pyproject.toml b/pyproject.toml index 121ac357f7..6e0c2c965a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", - "Framework :: Django :: 4.2", "Framework :: Django :: 5.0", "Framework :: Django :: 5.1", "Framework :: Django :: 5.2", @@ -31,7 +30,7 @@ classifiers = [ "Topic :: Internet :: WWW/HTTP", ] dynamic = [ "version" ] -dependencies = [ "django>=4.2" ] +dependencies = [ "django>=5.0" ] urls.Changelog = "https://www.django-rest-framework.org/community/release-notes/" urls.Funding = "https://fund.django-rest-framework.org/topics/funding/" urls.Homepage = "https://www.django-rest-framework.org" @@ -51,8 +50,6 @@ test = [ "pytest-cov==7.*", "pytest-django>=4.5.2,<5", - # Remove when dropping support for Django<5.0 - "pytz", ] docs = [ # MkDocs to build our documentation. @@ -75,7 +72,6 @@ optional = [ # setuptools is needed for coreapi (imports pkg_resources) "setuptools<82", ] -django42 = [ "django>=4.2,<5.0" ] django50 = [ "django>=5.0,<5.1" ] django51 = [ "django>=5.1,<5.2" ] django52 = [ "django>=5.2,<6.0" ] @@ -102,7 +98,7 @@ skip = [ ".tox" ] atomic = true multi_line_output = 5 extra_standard_library = [ "types" ] -known_third_party = [ "pytest", "_pytest", "django", "pytz", "uritemplate" ] +known_third_party = [ "pytest", "_pytest", "django", "uritemplate" ] known_first_party = [ "rest_framework", "tests" ] [tool.codespell] diff --git a/tests/test_fields.py b/tests/test_fields.py index e360793184..4f9dd0c00b 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -9,9 +9,7 @@ from unittest.mock import patch from zoneinfo import ZoneInfo -import django import pytest -import pytz from django.core.exceptions import ValidationError as DjangoValidationError from django.db.models import IntegerChoices, TextChoices from django.http import QueryDict @@ -1646,7 +1644,7 @@ def setup_class(cls): def assertUTC(self, tzinfo): """ - Check UTC for datetime.timezone, ZoneInfo, and pytz tzinfo instances. + Check UTC for datetime.timezone, ZoneInfo. """ assert ( tzinfo is utc or @@ -1684,34 +1682,6 @@ def test_should_render_date_time_in_default_timezone(self): assert rendered_date == rendered_date_in_timezone -@pytest.mark.skipif( - condition=django.VERSION >= (5,), - reason="Django 5.0 has removed pytz; this test should eventually be able to get removed.", -) -class TestPytzNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues): - """ - Invalid values for `DateTimeField` with datetime in DST shift (non-existing or ambiguous) and timezone with DST. - Timezone America/New_York has DST shift from 2017-03-12T02:00:00 to 2017-03-12T03:00:00 and - from 2017-11-05T02:00:00 to 2017-11-05T01:00:00 in 2017. - """ - valid_inputs = {} - invalid_inputs = { - '2017-03-12T02:30:00': ['Invalid datetime for the timezone "America/New_York".'], - '2017-11-05T01:30:00': ['Invalid datetime for the timezone "America/New_York".'] - } - outputs = {} - - class MockTimezone(pytz.BaseTzInfo): - @staticmethod - def localize(value, is_dst): - raise pytz.InvalidTimeError() - - def __str__(self): - return 'America/New_York' - - field = serializers.DateTimeField(default_timezone=MockTimezone()) - - @patch('rest_framework.utils.timezone.datetime_ambiguous', return_value=True) class TestNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues): """ diff --git a/tox.ini b/tox.ini index 00e5bd57b8..8eec6eb00c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,8 +1,8 @@ [tox] envlist = - {py310}-{django42,django51,django52} - {py311}-{django42,django51,django52} - {py312}-{django42,django51,django52,django60,djangomain} + {py310}-{django51,django52} + {py311}-{django51,django52} + {py312}-{django51,django52,django60,djangomain} {py313}-{django51,django52,django60,djangomain} {py314}-{django52,django60,djangomain} base @@ -18,7 +18,6 @@ setenv = dependency_groups = test optional - django42: django42 django50: django50 django51: django51 django52: django52