backednd iamge table updae
This commit is contained in:
@@ -36,10 +36,19 @@ class TasksAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
|
||||
|
||||
@admin.register(Images)
|
||||
class ImagesAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
|
||||
list_display = ['task', 'site', 'sector', 'image_type', 'status', 'position', 'created_at']
|
||||
list_display = ['get_content_title', 'site', 'sector', 'image_type', 'status', 'position', 'created_at']
|
||||
list_filter = ['image_type', 'status', 'site', 'sector']
|
||||
search_fields = ['task__title']
|
||||
ordering = ['task', 'position', '-created_at']
|
||||
search_fields = ['content__title', 'content__meta_title', 'task__title']
|
||||
ordering = ['-id'] # Sort by ID descending (newest first)
|
||||
|
||||
def get_content_title(self, obj):
|
||||
"""Get content title, fallback to task title if no content"""
|
||||
if obj.content:
|
||||
return obj.content.title or obj.content.meta_title or f"Content #{obj.content.id}"
|
||||
elif obj.task:
|
||||
return obj.task.title or f"Task #{obj.task.id}"
|
||||
return '-'
|
||||
get_content_title.short_description = 'Content Title'
|
||||
|
||||
def get_site_display(self, obj):
|
||||
"""Safely get site name"""
|
||||
|
||||
Reference in New Issue
Block a user