diff --git a/config/settings.py b/config/settings.py index 2af34e03b8..4ed45fd4fa 100644 --- a/config/settings.py +++ b/config/settings.py @@ -137,6 +137,7 @@ STATIC_ROOT = BASE_DIR / 'staticfiles' # Media root/url +# https://devcenter.heroku.com/articles/s3 MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR, "media") diff --git a/config/urls.py b/config/urls.py index 5e60699ee3..a7dbbf6cb2 100644 --- a/config/urls.py +++ b/config/urls.py @@ -15,7 +15,9 @@ Including another URLconf """ from django.contrib import admin from django.urls import include, path +from django.conf.urls.static import static +from config import settings import config.views import ultron.followup.urls import ultron.location.urls @@ -62,4 +64,4 @@ urlpatterns = [ # Administration path('admin/', admin.site.urls), -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/templates/peoples/gymnasts/details.html b/templates/peoples/gymnasts/details.html index 70c203e36d..37ab9a103b 100644 --- a/templates/peoples/gymnasts/details.html +++ b/templates/peoples/gymnasts/details.html @@ -14,7 +14,7 @@
{% if gymnast.picture %} - {{ gymnast }} + {{ gymnast }} {% endif %}

{{ gymnast.first_name }} {{ gymnast.last_name }}

diff --git a/ultron/people/migrations/0005_alter_gymnast_picture.py b/ultron/people/migrations/0005_alter_gymnast_picture.py new file mode 100644 index 0000000000..91cca05dd5 --- /dev/null +++ b/ultron/people/migrations/0005_alter_gymnast_picture.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.8 on 2021-12-22 08:35 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('people', '0004_alter_gymnast_picture'), + ] + + operations = [ + migrations.AlterField( + model_name='gymnast', + name='picture', + field=models.ImageField(blank=True, null=True, upload_to='gymnast'), + ), + ] diff --git a/ultron/people/views.py b/ultron/people/views.py index d900c421c6..b61f995947 100644 --- a/ultron/people/views.py +++ b/ultron/people/views.py @@ -343,10 +343,8 @@ def gymnast_create_or_update(request, gymnast_id=None): if request.method == "POST": gymnast_form = GymnastForm(request.POST, request.FILES, instance=gymnast) - print(gymnast_form) - if gymnast_form.is_valid(): - # handle_uploaded_file(request.FILES['file']) + if gymnast_form.is_valid(): gymnast = gymnast_form.save() return HttpResponseRedirect("/gymnast/details/" + str(gymnast.id)) else: