hi guys, I am facing a problem that is I want to add a row from a different model to the current model ( both model has same fields ) . furthermore I want a functionality to create a exercise but if you want you can add that exercise is already provided in a diff model here is the code…
this is exercise model that has preloaded exercise
class Exercise(models.Model):
body_part = models.CharField(max_length=255)
muscle_name = models.CharField(max_length=255)
exercise_name = models.CharField(max_length=255)
sets = models.CharField(max_length=255)
reps = models.CharField(max_length=255)
def __str__(self) -> str:
return self.exercise_name
class Meta:
ordering = ['body_part']
workout structure model that contains exercises you have create but I want to give feature to add this exercise from above model “Exercise”
class WorkoutStructure(models.Model):
workout = models.ForeignKey(WorkoutList, on_delete=models.CASCADE, related_name='workout_lists')
body_part = models.CharField(max_length=255,default="", blank=True)
muscle_name = models.CharField(max_length=255,default="", blank=True)
exercise_name = models.CharField(max_length=255, default="", blank=True)
sets = models.CharField(max_length=255, default="", blank=True)
reps = models.CharField(max_length=255, default="", blank=True)
def __str__(self) -> str:
return self.exercise_name
class Meta:
ordering = ['body_part']
please someone help me implement this