def _check_date_hierarchy(self, obj):

        if obj.date_hierarchy is None:
            return []
        else:
            try:
                field = obj.model._meta.get_field(obj.date_hierarchy)
            except FieldDoesNotExist:
                return refer_to_missing_field(
                    option='date_hierarchy', field=obj.date_hierarchy,
                    model=obj.model, obj=obj, id='admin.E127',
                )
            else:
                if not isinstance(field, (models.DateField, models.DateTimeField)):
                    return must_be('a DateField or DateTimeField', option='date_hierarchy', obj=obj, id='admin.E128')
                else:
                    return []
Check that date_hierarchy refers to DateField or DateTimeField.
dataset/ETHPy150Open django/django/django/contrib/admin/checks.py/ModelAdminChecks._check_date_hierarchy