Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Check if the form values are valid before trying to save it

Roland Geider5a43a3b47637
diff --git a/manager/views.py b/manager/views.py
index a46902b55..9f6d2285d 100644
--- a/manager/views.py
+++ b/manager/views.py
@@ -312,9 +312,11 @@ def exercise_category_edit(request, id):
if request.method == 'POST':
category_form = ExerciseCategoryForm(request.POST, instance=category)
- category = category_form.save()
- return HttpResponseRedirect('/exercise/overview/')
+ # If the data is valid, save and redirect
+ if category_form.is_valid():
+ category = category_form.save()
+ return HttpResponseRedirect('/exercise/overview/')
else:
category_form = ExerciseCategoryForm(instance=category)