diff --git a/apps/note/models/notes.py b/apps/note/models/notes.py index 9e3c0a9e..ea62bd75 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 00000000..f933bc34 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 a58d4817..007ceadb 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 303e229a..385ce991 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 f9f9eb03..c3301fd6 100644 --- a/templates/member/profile_detail.html +++ b/templates/member/profile_detail.html @@ -5,7 +5,9 @@