﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35628	date_hierarchy doesn't support GenerateField with output_field set to DateTimeField or DateField	john-parton	john-parton	"If you have a GeneratedField with output_field set to DateField or DateTimeField, you cannot use it in the admin as a `date_hierarchy` because of a check. If you skip the check, it actually works just fine in my testing. I believe this the check could be adjusted to account for this.


{{{
# models.py
class TestModel(models.Model):
    date_range = DateTimeRangeField(_(""Date range""))
    start_date = models.GeneratedField(
        expression=Lower(""date_range""),
        output_field=models.DateTimeField(),
        db_persist=True,
    )
    
  

# admin.py
class TestAdmin(admin.ModelAdmin):
    date_hierarchy = ""start_date""

    # Skipping checks actually makes this work exactly correctly
    def check(self, *args, **kwargs):
        return ()

}}}

I'll see if I can whip up a patch."	Bug	closed	contrib.admin	5.0	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
