code: def get_compiler(self, *args, **kwargs):
          
          if self.querytime.active and \
                  (not hasattr(self, '_querytime_filter_added') or
                      not self._querytime_filter_added):
              time = self.querytime.time
              if time is None:
                  self.add_q(Q(version_end_date__isnull=True))
              else:
                  self.add_q(
                      (Q(version_end_date__gt=time) |
                       Q(version_end_date__isnull=True)) &
                      Q(version_start_date__lte=time)
                  )
              # Ensure applying these filters happens only a single time (even
              # if it doesn't falsify the query, it's just not very comfortable
              # to read)
              self._querytime_filter_added = True
          return super(VersionedQuery, self).get_compiler(*args, **kwargs)
docs: Add the query time restriction limit at the last moment.  Applying it
          earlier (e.g. by adding a filter to the queryset) does not allow the
          caching of related object to work (they are attached to a queryset;
          filter() returns a new queryset).