Datetime.now () abnormality - Python

I am serving a Python application through Django . In the application, I store the classic created field in several tables.

Here's what a field looks like in a Django form:

created = models.DateTimeField(blank=True, default=datetime.now())

Unfortunately, datetime.now () is not accurate. In fact, in the database, I have rowsets with the same timestamp.

The datetime.now () value changes every 30-45 minutes.


My Django is available on Windows Server 2005 for IIS6.

Help will be awesome!

+5
source share
3 answers

datetime.now() , , .

auto_now_add = True

created = models.DateTimeField(auto_now_add=True)

edit: 'blank', auto.

+6

, . datetime.now() - , , , .

:

created = models.DateTimeField(blank=True, default=datetime.now)

.. .

( auto_now_add=True).

+10
+2

All Articles