i am trying to develop a workout-tracking website with django.
the idea is, to create one view to "plan" and "create" the workout, and another view to "execute" one of the saved workouts.
Plan-Mode
class Workout(models.Model):
title = models.CharField(max_length=100)
date_created = models.DateTimeField(default=timezone.now)
date_updated = models.DateTimeField(auto_now_add=timezone.now)
creator = models.ForeignKey(User, on_delete=models.CASCADE)
class Excercise(models.Model):
exercise = models.CharField(max_length=100)
sets = models.PositiveIntegerField()
reps = models.PositiveIntegerField()
weight = models.DecimalField(max_digits=5,decimal_places=2)
date_created = models.DateTimeField(default=timezone.now)
date_updated = models.DateTimeField(auto_now_add=timezone.now)
workout = models.ForeignKey(Workout,
on_delete=models.CASCADE)
Data could look like:
"Leg Workout": (workout.title)
{
("Squats", 5, 5, 35.5),
("Leg Press",3,8,55.15),
}
this is it for the Plan-Mode, works fine! and now im stuck!
the Exe-Mode should look like this:
title:Leg Workout
exercise: Squats
Set 1: n of 5 Reps with 35.5kg
Set 2: n of 5 Reps with 35.5kg
Set 3: n of 5 Reps with 35.5kg
Set 4: n of 5 Reps with 35.5kg
Set 5: n of 5 Reps with 35.5kg
exercise: Leg Press
Set 1: n of 8 Reps with 55.15kg
Set 2: n of 8 Reps with 55.15kg
Set 3: n of 8 Reps with 55.15kg
i dont know how to handle the sets, reps and weight attributes. i guess i'd have to create a dynamic Model (for e.g. WorkoutSession), and dynamically add attributes depending of the amount of sets defined? (like in this post Django dynamic model fields)
any help is highly appreciated.