diff --git a/main/admin.py b/main/admin.py
index 884574d..a9a84c0 100644
--- a/main/admin.py
+++ b/main/admin.py
@@ -1,5 +1,5 @@
from django.contrib import admin
-from .models import Calculator, Course, ReviewLike, ScoreComponent, Tag, Profile, Review, ReviewTag
+from .models import Calculator, Course, ReviewLike, ScoreComponent, Tag, Profile, Review, ReviewTag, Question, Answer, QuestionImageAdmin, AnswerImageAdmin
# Register your models here.
admin.site.register(Course)
@@ -10,3 +10,5 @@
admin.site.register(ReviewTag)
admin.site.register(Calculator)
admin.site.register(ScoreComponent)
+admin.site.register(Question, QuestionImageAdmin)
+admin.site.register(Answer, AnswerImageAdmin)
\ No newline at end of file
diff --git a/main/models.py b/main/models.py
index ccfab7f..963439d 100644
--- a/main/models.py
+++ b/main/models.py
@@ -9,6 +9,8 @@
import environ
from django.utils import timezone
+from django.utils.html import format_html
+from django.contrib import admin
env = environ.Env()
expires_in = 60*60*7 # 7 Hours
@@ -260,4 +262,16 @@ class Meta:
unique_together = ('user', 'content_type', 'object_id')
def __str__(self):
- return f'{self.user.username} liked {self.content_object}: {self.content_type} {self.object_id}'
\ No newline at end of file
+ return f'{self.user.username} liked {self.content_object}: {self.content_type} {self.object_id}'
+
+class QuestionImageAdmin(admin.ModelAdmin):
+ def image_tag(self, obj):
+ return format_html(''.format(get_attachment_presigned_url(obj.attachment)))
+
+ list_display = ['question_text','image_tag',]
+
+class AnswerImageAdmin(admin.ModelAdmin):
+ def image_tag(self, obj):
+ return format_html(''.format(get_attachment_presigned_url(obj.attachment)))
+
+ list_display = ['answer_text','image_tag',]
\ No newline at end of file