diff --git a/apps/note/models/notes.py b/apps/note/models/notes.py index 9e3c0a9e25773cdf9178771ff67e7a54b3e0aec8..ea62bd75622077e52b6d4003909fa8e2123ec546 100644 --- a/apps/note/models/notes.py +++ b/apps/note/models/notes.py @@ -44,6 +44,7 @@ class Note(PolymorphicModel): verbose_name=_('display image'), max_length=255, blank=True, + default='pic/default.png' ) created_at = models.DateTimeField( verbose_name=_('created at'), diff --git a/media/pic/default.png b/media/pic/default.png new file mode 100644 index 0000000000000000000000000000000000000000..f933bc341619178775520150d514effb2339b10a Binary files /dev/null and b/media/pic/default.png differ diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index a58d4817df2bfa86462ca5283cbdaea58073964e..007ceadb821c987b3143a61393fd1892987c232c 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -92,6 +92,7 @@ TEMPLATES = [ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.request', + # 'django.template.context_processors.media', ], }, }, @@ -188,3 +189,5 @@ STATIC_URL = '/static/' ALIAS_VALIDATOR_REGEX = r'' +MEDIA_ROOT=os.path.join(BASE_DIR,"media") +MEDIA_URL='/media/' diff --git a/note_kfet/urls.py b/note_kfet/urls.py index 303e229aaed0ea291620383ce71e7c27fecbf410..385ce991dcf2c1345d728a98d8acb21af2d12a8c 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -1,9 +1,11 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from django.conf import settings from django.contrib import admin from django.urls import path, include from django.views.generic import RedirectView +from django.conf.urls.static import static urlpatterns = [ # Dev so redirect to something random @@ -22,3 +24,5 @@ urlpatterns = [ # Include Django REST API path('api/', include('api.urls')), ] + +urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) diff --git a/templates/member/profile_detail.html b/templates/member/profile_detail.html index f9f9eb03babd262291751bfb191a122223374e66..c3301fd6e9de6ba07ff2a870a6e7b1be7dc19f95 100644 --- a/templates/member/profile_detail.html +++ b/templates/member/profile_detail.html @@ -5,7 +5,9 @@ <div class="row mt-4"> <div class="col-md-3 mb-4"> <div class="card bg-light shadow"> - <img src="{{ object.note.display_image }}" class="card-img-top" alt=""> + <div class="card-top text-center"> + <img src="{{ object.note.display_image.url }}" class="img-thumbnail mt-2" > + </div> <div class="card-body"> <dl class="row"> <dt class="col-xl-6">{% trans 'name'|capfirst %}, {% trans 'first name' %}</dt>