From 1004b88779710847000a88cffb13c59bf9e40d8c Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Tue, 1 May 2018 14:44:56 -0400 Subject: [PATCH] Make media posting work, with limitations. Doesn't work with replies (for reasons I don't 100% understand yet). Only one media field set in the form, though the rest could be added. --- brutaldon/settings.py | 4 ++++ brutaldon/templates/main/post_partial.html | 19 ++++++++++++++-- brutaldon/views.py | 26 ++++++++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/brutaldon/settings.py b/brutaldon/settings.py index dfb5080..1a444a0 100644 --- a/brutaldon/settings.py +++ b/brutaldon/settings.py @@ -127,3 +127,7 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static') # Sanitizer settings SANITIZER_ALLOWED_TAGS = ['a', 'p', 'img', 'br', 'i', 'strong'] SANITIZER_ALLOWED_ATTRIBUTES = ['href', 'src'] + +# File upload settings. +# Important: media will not work if you change this. +FILE_UPLOAD_HANDLERS = ["django.core.files.uploadhandler.TemporaryFileUploadHandler"] diff --git a/brutaldon/templates/main/post_partial.html b/brutaldon/templates/main/post_partial.html index 0a3544b..3dc5243 100644 --- a/brutaldon/templates/main/post_partial.html +++ b/brutaldon/templates/main/post_partial.html @@ -1,9 +1,9 @@ {% load widget_tweaks %} {% if reply %} -
+ {% else %} - + {% endif %} {% csrf_token %} @@ -32,6 +32,21 @@ + +
+ +
+ {% render_field form.media_file_1 %} +
+
+ {% render_field form.media_text_1 class+="input" placeholder="Describe attachment" %} +
+
+ +
+ {{ form.errors }} +
+