AttributeError: object type 'datetime.date' does not have attribute 'now'

Using these lines of code:

from datetime import date self.date_start_processing = date.now() 

I get this error:

AttributeError: object type 'datetime.date' does not have attribute 'now'

How can i solve this?

Thanks.

+4
source share
1 answer

You need to use

  import datetime now = datetime.datetime.now() 

Or, if you are using django 1.4+ and have a time zone, you should use

  django.utils.timezone.now() 
+16
source

Source: https://habr.com/ru/post/1469533/


All Articles