Skip to content

Commit 658fc60

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents b7493dd + bcbc4b9 commit 658fc60

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

django/core/management/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def create_parser(self, prog_name, subcommand, **kwargs):
345345
parser,
346346
"--traceback",
347347
action="store_true",
348-
help="Raise on CommandError exceptions.",
348+
help="Display a full stack trace on CommandError exceptions.",
349349
)
350350
self.add_base_argument(
351351
parser,

docs/ref/models/fields.txt

+19
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,15 @@ Any combination of these options will result in an error.
798798
instead of a ``DateField`` and deciding how to handle the conversion from
799799
datetime to date at display time.
800800

801+
.. warning:: Always use :class:`DateField` with a ``datetime.date`` instance.
802+
803+
If you have a ``datetime.datetime`` instance, it's recommended to convert
804+
it to a ``datetime.date`` first. If you don't, :class:`DateField` will
805+
localize the ``datetime.datetime`` to the :ref:`default timezone
806+
<default-current-time-zone>` and convert it to a ``datetime.date``
807+
instance, removing its time component. This is true for both storage and
808+
comparison.
809+
801810
``DateTimeField``
802811
-----------------
803812

@@ -810,6 +819,16 @@ The default form widget for this field is a single
810819
:class:`~django.forms.DateTimeInput`. The admin uses two separate
811820
:class:`~django.forms.TextInput` widgets with JavaScript shortcuts.
812821

822+
.. warning:: Always use :class:`DateTimeField` with a ``datetime.datetime``
823+
instance.
824+
825+
If you have a ``datetime.date`` instance, it's recommended to convert it to
826+
a ``datetime.datetime`` first. If you don't, :class:`DateTimeField` will
827+
use midnight in the :ref:`default timezone <default-current-time-zone>` for
828+
the time component. This is true for both storage and comparison. To
829+
compare the date portion of a :class:`DateTimeField` with a
830+
``datetime.date`` instance, use the :lookup:`date` lookup.
831+
813832
``DecimalField``
814833
----------------
815834

docs/topics/i18n/timezones.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Overview
99

1010
When support for time zones is enabled, Django stores datetime information in
1111
UTC in the database, uses time-zone-aware datetime objects internally, and
12-
translates them to the end user's time zone in templates and forms.
12+
converts them to the end user's time zone in forms. Templates will use the
13+
:ref:`default time zone <default-current-time-zone>`, but this can be updated
14+
to the end user's time zone through the use of :ref:`filters and tags
15+
<time-zones-in-templates>`.
1316

1417
This is handy if your users live in more than one time zone and you want to
1518
display datetime information according to each user's wall clock.

tests/migrations/test_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1380,8 +1380,8 @@ def test_add_field(self):
13801380
self.assertEqual(sorted(definition[2]), ["field", "model_name", "name"])
13811381

13821382
@skipUnlessDBFeature("supports_stored_generated_columns")
1383-
def test_add_generate_field(self):
1384-
app_label = "test_add_generate_field"
1383+
def test_add_generated_field(self):
1384+
app_label = "test_add_generated_field"
13851385
project_state = self.apply_operations(
13861386
app_label,
13871387
ProjectState(),

0 commit comments

Comments
 (0)