Add thumbnails on search results

This commit is contained in:
Claude Paroz 2018-10-14 19:59:04 +02:00
parent f45b5d842b
commit ea6bb20ab3
4 changed files with 36 additions and 4 deletions

View file

@ -17,6 +17,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'easy_thumbnails',
'recette',
]
@ -75,4 +76,10 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
THUMBNAIL_ALIASES = {
'': {
'thumbnail': {'size': (120, 120), 'crop': True},
},
}
from .local_settings import *

View file

@ -1,5 +1,7 @@
from django.conf import settings
from django.contrib import admin
from django.urls import path
from django.views.static import serve
from recette.views import home, recette
@ -9,3 +11,10 @@ urlpatterns = [
path('', home, name='home'),
path('recette/<int:pk>/', recette, name='recette'),
]
if settings.DEBUG:
urlpatterns += [
path('media/<path:path>', serve, {
'document_root': settings.MEDIA_ROOT,
}),
]