After some further investigation, the generated by the date_hierarchy for the DocumentAdmin is, for example, http://localhost:8098/admin/memorabilia/document/?created__day=25&created__month=5&created__year=2018. There are documents with a created date of May 25, 2018. However, the Document field created is a DateTime field, so the time is also part of the field. I also have USE_TZ = True in settings.py, and I updated mysql to use time zones as outlined in the django docs ( https://docs.djangoproject.com/en/2.0/ref/databases/#mysql-time-zone-definitions and https://dev.mysql.com/doc/refman/8.0/en/mysql-tzinfo-to-sql.html).
I am not sure of the time zone issue is a red herring or not. Anyone have a suggestion on how to debug the problem? Thanks! Mark On Thu, Jun 14, 2018 at 2:02 PM, Mark Phillips <m...@phillipsmarketing.biz> wrote: > I have two related models, Document and DocumentMetaData, and two separate > ModelAdmins (DocumentAdmin, DocumentMetaDataAdmin) where I can't seem to > get list_filter or date_hierarchy to work. All the other aspects of the > admins work. > > When I say list_filter or date_hierarchy don't work, I mean they display > the right data on the admin page (filters on the right, date breadcrumbs on > the top), but when I select either a filter or a date in the date hierarchy > (the drill down works properly), they don't change the list of items in the > admin page. They don't do the filtering part of their job, they just look > pretty on the admin page. ;) > > I am not sure how to debug this, as there are no error messages on the > console. How would you suggest I debug this? > > Thanks! > > Mark > > class Document(Model): > document_id = models.AutoField(primary_key=True) > > # Document states > PRIVATE = 1 > PENDING = 200 > PUBLISHED = 300 > DOCUMENT_STATE = ( > (PRIVATE, 'private'), > (PENDING, 'pending'), > (PUBLISHED, 'published'), > ) > document_state = models.IntegerField(choices=DOCUMENT_STATE, > default=PRIVATE, verbose_name="state") > > # Document types > documentType_id = models.ForeignKey(DocumentType, > on_delete=models.CASCADE, verbose_name="document type", ) > > # Document fields > #title = models.CharField('title', max_length=description) > #200 = models.TextField('description') > created = models.DateTimeField(editable=False, verbose_name="date > created") > updated = models.DateTimeField(editable=False, verbose_name="last > update") > storage_file_name = models.FileField('File name', > upload_to=unique_file_path) > thumb_storage = models.FileField(editable=False,) > original_file_name = models.CharField(editable=False, max_length=200) > computed_sha256 = models.CharField(editable=False, max_length=64) > > .....rest of code left out for sake of brevity...... > > class DocumentAdmin(admin.ModelAdmin): > form = DocumentForm > list_display = ('get_document_type', 'document_state', 'get_title', > 'get_decade', 'original_file_name', 'created', 'storage_file_name', > 'get_thumb', ) > ordering = ('created',) > readonly_fields = ('get_thumb', ) > search_fields = ('original_file_name',) > list_filter = ('updated', 'created', 'documentType_id', > 'document_state', ) > date_hierarchy = 'created' > > .....rest of code left out for sake of brevity...... > > class DocumentMetaData(Model): > documentMetaData_id = models.AutoField(primary_key=True) > document_id = models.ForeignKey(Document, on_delete=models.CASCADE, > verbose_name="document file name") > metadata = JSONField(blank=True) > > .....rest of code left out for sake of brevity...... > > class DocumentMetaDataAdmin(admin.ModelAdmin): > form = DocumentMetaDataForm > list_display = ('get_document_name', 'document_id', 'metadata', > 'get_image_1', ) > #ordering = ('created',) > readonly_fields = ('get_document_name', 'get_image_1', 'get_image_2', ) > search_fields = ('document_id__original_file_name',) > list_filter = ('document_id', ) > ordering = ('document_id__created',) > date_hierarchy = 'document_id__created' > > .....rest of code left out for sake of brevity...... > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEqej2PuN2GYd4hhaBR-bZ687NJZ8MFW6YT3ERfcd%3DdF%2BSR-4Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.