Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/api-guide/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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.
Expand All @@ -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" ]
Expand All @@ -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]
Expand Down
32 changes: 1 addition & 31 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down
7 changes: 3 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +18,6 @@ setenv =
dependency_groups =
test
optional
django42: django42
django50: django50
django51: django51
django52: django52
Expand Down