2014-11-06 72 views
3

我關心涉及日期時間模塊的腳本。因爲腳本中還有其他打印語句,所以我必須禁止'對象在時區處於活動狀態時收到了天真的日期時間'。我的代碼如下壓制django天真日期時間警告

腳本:

from datetime import datetime 
date = datetime.now() 

objName = className.objects.create(param=value, param=value, param=value, time=date, attachment=attachment) 

models.py

class className(models.MOdel): 
    t = models.DateTimeField(null=True, blank=True) 

我怎樣才能抑制天真的日期時間的警告?

+0

的可能重複的[RuntimeWarning:DateTimeField字段接收到的日期時間幼稚(http://stackoverflow.com/questions/18622007/runtimewarning-datetimefield-received- a-naive-datetime) – 2015-08-10 15:47:07

回答

0

只是禁用時區的使用,如stated in the documentation:

USE_TZ = False 
+1

它已被設置爲false。有沒有辦法抑制錯誤信息?我的意思是我不希望他們出現在終端。 – cutteeth 2014-11-07 04:27:48

相關問題