Django QuerySet empty query solutions for DateTimeField time field

Today in use in Django filter () method DateTimeField encountered when the query field problems, scratching one afternoon, finally resolved, I think it took an afternoon get to the next record it (silent) ..... .

Problem Description:

      date = "2017-12-31“

       = DataTest.objects.filter flagcode (flagcode__icontains = flagcode, takeofftime__year no problem = date.year), you can check, but with __month, __ day, __ when the date is empty, find technical documents that are in default and Django about the time zone, change the settings in the USE_TZ Flase, can be the perfect solution:

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = False

        

       

        

Guess you like

Origin www.cnblogs.com/yuejucai/p/12060333.html