यह त्रुटि यह दर्शाती है कि पाइथन द्वारा कितनी बार संग्रहीत किया जाता है।
There are two kinds of date and time objects: “naive” and “aware”. This distinction refers to whether the object has any notion of time zone, daylight saving time, or other kind of algorithmic or political time adjustment.
Django documentation भी कहा गया है कि:
When time zone support is disabled, Django uses naive datetime objects in local time. This is simple and sufficient for many use cases. In this mode, to obtain the current time, you would write:
import datetime
now = datetime.datetime.now()
When time zone support is enabled, Django uses time-zone-aware datetime objects. If your code creates datetime objects, they should be aware too. In this mode, the example above becomes:
import datetime
from django.utils.timezone import utc
now = datetime.datetime.utcnow().replace(tzinfo=utc)
आप यह निर्धारित करना चाहिए या नहीं, आप अपनी साइट में समय क्षेत्र जागरूकता चाहते हैं और अजगर documentation के अनुसार फिर तदनुसार अपने संग्रहीत समय समायोजित करें। डीटी अनुभवहीन करने के लिए आप pytz module का उपयोग करें और क्या कर सकते हैं एक के बारे में पता बदलने के लिए इस:
naive_dt = aware_dt.replace(tzinfo=None)
यह काम करता है क्योंकि सभी अजगर datetimes एक वैकल्पिक समय क्षेत्र विशेषता, tzinfo
, जो डीटी के बारे में जानकारी स्टोर करने के लिए इस्तेमाल किया जा सकता यूटीसी से ऑफसेट है पहर।
स्रोत
2012-05-15 05:16:40
संभावित डुप्लिकेट [ऑफसेट-बेवकूफ और ऑफसेट-जागरूक डेटाटाइम घटा नहीं सकता] [http://stackoverflow.com/questions/796008/cant-subtract-offset-naive-and-offset-aware-datetimes) – user1023979