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/CAEqej2OP%3DFCyPj5DuLaM3SBMb_ShUEvMLUMNz%3DgmVJYcp7wzZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to