diff --git a/config/settings.py b/config/settings.py index cdd8b02db1..2af34e03b8 100644 --- a/config/settings.py +++ b/config/settings.py @@ -137,8 +137,8 @@ STATIC_ROOT = BASE_DIR / 'staticfiles' # Media root/url -MEDIA_URL = "/media/gymnast/" -MEDIA_ROOT = os.path.join(BASE_DIR, "/media/gymnast") +MEDIA_URL = "/media/" +MEDIA_ROOT = os.path.join(BASE_DIR, "media") # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field diff --git a/templates/peoples/gymnasts/create.html b/templates/peoples/gymnasts/create.html index dda77e973d..c449bc493a 100644 --- a/templates/peoples/gymnasts/create.html +++ b/templates/peoples/gymnasts/create.html @@ -8,7 +8,7 @@

{% if gymnast_id %}Edit{% else %}Add{% endif %} Gymnast

-
+ {% csrf_token %}
diff --git a/ultron/people/models.py b/ultron/people/models.py index cbeffff636..b95c5fd0ca 100644 --- a/ultron/people/models.py +++ b/ultron/people/models.py @@ -34,7 +34,7 @@ class Gymnast(Markdownizable): verbose_name="# Training by week" ) hours_by_week = models.PositiveSmallIntegerField(verbose_name="# Hours by week") - picture = models.ImageField(upload_to="media/gymnast", null=True, blank=True) + picture = models.ImageField(upload_to="gymnast", null=True, blank=True) def __str__(self): return u"%s, %s" % (self.last_name, self.first_name) diff --git a/ultron/people/views.py b/ultron/people/views.py index 14833a4d29..d900c421c6 100644 --- a/ultron/people/views.py +++ b/ultron/people/views.py @@ -342,10 +342,11 @@ def gymnast_create_or_update(request, gymnast_id=None): data = {} if request.method == "POST": - gymnast_form = GymnastForm(request.POST, instance=gymnast) + gymnast_form = GymnastForm(request.POST, request.FILES, instance=gymnast) print(gymnast_form) - if gymnast_form.is_valid(): + if gymnast_form.is_valid(): + # handle_uploaded_file(request.FILES['file']) gymnast = gymnast_form.save() return HttpResponseRedirect("/gymnast/details/" + str(gymnast.id)) else: