[Django]-How to display only date from datetime field in modelAdmin in Django admin panel?

6👍

You can add a method to the ModelAdmin class.

@admin.register(YourModel)
class YourModelAdmin(admin.ModelAdmin):
    list_display = ('get_date_formatted',)

    def get_date_formatted(self, obj):
        if obj:
            return obj.date.date()
    get_date_formatted.admin_order_field = 'date'
    get_date_formatted.short_description = 'date'

Leave a comment