'Extract year uses a BETWEEN filter to compare the year to allow indexes
to be used.'

def test_extract_year_exact_lookup(self):

    start_datetime = datetime(2015, 6, 15, 14, 10)
    end_datetime = datetime(2016, 6, 15, 14, 10)
    if settings.USE_TZ:
        start_datetime = timezone.make_aware(start_datetime, is_dst=False)
        end_datetime = timezone.make_aware(end_datetime, is_dst=False)
    self.create_model(start_datetime, end_datetime)
    self.create_model(end_datetime, start_datetime)
    qs = DTModel.objects.filter(start_datetime__year__exact=2015)
    self.assertEqual(qs.count(), 1)
    query_string = str(qs.query).lower()
    self.assertEqual(query_string.count('    between    '), 1)
    self.assertEqual(query_string.count('extract'), 0)
    qs = DTModel.objects.filter(start_datetime__year=2015)
    self.assertEqual(qs.count(), 1)
    query_string = str(qs.query).lower()
    self.assertEqual(query_string.count('    between    '), 1)
    self.assertEqual(query_string.count('extract'), 0)
    qs = DTModel.objects.filter(start_date__year=2015)
    self.assertEqual(qs.count(), 1)
    query_string = str(qs.query).lower()
    self.assertEqual(query_string.count('    between    '), 1)
    self.assertEqual(query_string.count('extract'), 0)
