# timezone.now() in tutorial02 when "python manage.py shell".

**URL:** <https://forum.djangoproject.com/t/timezone-now-in-tutorial02-when-python-manage-py-shell/23988>\
**Category:** Getting Started\
**Created:** [September 19, 2023, 5:22pm UTC](https://forum.djangoproject.com/t/timezone-now-in-tutorial02-when-python-manage-py-shell/23988 "2023-09-19T17:22:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsf-tree](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jsf-tree/32/16023_2.png) [@jsf-tree](https://forum.djangoproject.com/u/jsf-tree)\
**Post date:** [September 19, 2023, 5:22pm UTC](https://forum.djangoproject.com/t/timezone-now-in-tutorial02-when-python-manage-py-shell/23988/1 "2023-09-19T17:22:07Z")

</div>

Hi, I might have a suggestion to [Tutorial 02](https://docs.djangoproject.com/en/4.2/intro/tutorial02/) when it says `python manage.py shell` runs python taking **settings.py** into account. Later on, it suggests using `timezone.now()` for the Question instantiation (mind you timezone is imported with `from django.utils import timezone`).

I would expect that `timezone.now()` would bring up the time in the timezone I set in **settings.py** , but it has not. It is not much intuitive because the learner is led to think they are using the **settings.py** , while only a `timezone.localtime()` would bring up the timezone. I hence suggest we had a note that says `timezone.localtime()` will output the time with the settings.

On the other hand, I believe there could be a reason why `timezone.now()` is used in the tutorial, but I cannot see it — maybe the best practice with databases in Django is to keep all in UTC to avoid timezone conversion errors? — Well, if that is the case, I suspect a little hint would come in handy.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 19, 2023, 5:32pm UTC](https://forum.djangoproject.com/t/timezone-now-in-tutorial02-when-python-manage-py-shell/23988/2 "2023-09-19T17:32:57Z")

</div>

It is a common practice to only store UTC time in your database, and then convert it for display as necessary.

It’s not just a “best practice for Django” - it’s a best practice overall - precisely because of the potential problems with timezone conversion / DST

The very first paragraph in the docs for [Time zones](https://docs.djangoproject.com/en/4.2/topics/i18n/timezones/)

> When support for time zones is enabled, Django stores datetime information in UTC in the database, uses time-zone-aware datetime objects internally, and translates them to the end user’s time zone in templates and forms.

and then in the third paragraph:

> Even if your website is available in only one time zone, it’s still good practice to store data in UTC in your database. …

Also in the [Playing with the API](https://docs.djangoproject.com/en/4.2/intro/tutorial02/#playing-with-the-api) section of that page, there’s this note that references the above docs:

> Note the addition of `import datetime` and `from django.utils import timezone` , to reference Python’s standard [`datetime`](https://docs.python.org/3/library/datetime.html#module-datetime) module and Django’s time-zone-related utilities in [`django.utils.timezone`](https://docs.djangoproject.com/en/4.2/ref/utils/#module-django.utils.timezone), respectively. If you aren’t familiar with time zone handling in Python, you can learn more in the [time zone support docs](https://docs.djangoproject.com/en/4.2/topics/i18n/timezones/).

---

<div class="post-metadata">

**Author:** ![jsf-tree](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jsf-tree/32/16023_2.png) [@jsf-tree](https://forum.djangoproject.com/u/jsf-tree)\
**Post date:** [September 19, 2023, 5:38pm UTC](https://forum.djangoproject.com/t/timezone-now-in-tutorial02-when-python-manage-py-shell/23988/3 "2023-09-19T17:38:35Z")

</div>

Oh yeah, sure. I actually might have read it there yesterday night, but forgot it.  
Thank you very much for the quick reply, Ken!
