Revert "Add some admin useful informations and SQL optimisation"
This reverts commit 9020074df8.
This commit is contained in:
parent
9020074df8
commit
71066e5507
3 changed files with 4 additions and 19 deletions
|
|
@ -25,10 +25,6 @@ class GalleryAdmin(admin.ModelAdmin):
|
|||
|
||||
get_tags.short_description = _("tags")
|
||||
|
||||
def get_queryset(self, request):
|
||||
# Cette étape est correcte et essentielle
|
||||
return super().get_queryset(request).prefetch_related("tags")
|
||||
|
||||
|
||||
class PhotoAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
|
|
@ -39,9 +35,8 @@ class PhotoAdmin(admin.ModelAdmin):
|
|||
"view_count",
|
||||
"admin_thumbnail",
|
||||
"get_owner",
|
||||
"get_galleries"
|
||||
)
|
||||
list_filter = ["date_added", "is_public", "owner","galleries"]
|
||||
list_filter = ["date_added", "is_public", "owner"]
|
||||
search_fields = ["title", "slug", "caption"]
|
||||
list_per_page = 25
|
||||
prepopulated_fields = {"slug": ("title",)}
|
||||
|
|
@ -50,16 +45,6 @@ class PhotoAdmin(admin.ModelAdmin):
|
|||
|
||||
def get_owner(self, obj):
|
||||
return obj.owner.username
|
||||
|
||||
def get_queryset(self, request):
|
||||
# Précharge les objets 'galleries' en une seule requête supplémentaire
|
||||
return super().get_queryset(request).prefetch_related("owner",'galleries')
|
||||
|
||||
def get_galleries(self, obj):
|
||||
return ", ".join([g.title for g in obj.galleries.all()])## get all linked galeries
|
||||
|
||||
get_galleries.short_description = _("Gallery")
|
||||
get_galleries.admin_order_field = 'galleries__title'
|
||||
|
||||
get_owner.admin_order_field = "owner"
|
||||
get_owner.short_description = _("owner")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.validators import RegexValidator
|
||||
from django.core.cache import cache
|
||||
from django.core.cache import caches
|
||||
from django.db import models
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.urls import reverse
|
||||
|
|
@ -25,7 +25,7 @@ from django.utils.timezone import now
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from PIL import Image, ImageFile, ImageFilter
|
||||
|
||||
caches = cache
|
||||
|
||||
|
||||
logger = logging.getLogger("photologue.models")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue