Self hosted FLOSS fitness/workout, nutrition and weight tracker
If there are no other sets, order__max will be None, check for that
Roland Geidera9944677a0c2
diff --git a/wger/manager/views/set.py b/wger/manager/views/set.pyindex d0d1603b0..a797fd167 100644--- a/wger/manager/views/set.py+++ b/wger/manager/views/set.py@@ -96,7 +96,7 @@ def edit_set(request, id, day_id, set_id=None):if not workout_set.order:max_order = day.set_set.select_related().aggregate(models.Max('order'))- workout_set.order = max_order['order__max'] + 1+ workout_set.order = (max_order['order__max'] or 0) + 1workout_set.save()# The exercises are ManyToMany in DB, so we have to save with this function