Files
WerkoutAPI/equipment/models.py
2024-06-23 22:51:58 -05:00

30 lines
1017 B
Python

from django.db import models
from exercise.models import Exercise
# Create your models here.
class Equipment(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
is_weight = models.BooleanField(default=False)
category = models.CharField(null=True, blank=True, max_length=64)
name = models.CharField(null=True, blank=True, max_length=64)
def __str__(self):
return self.category + " : " + self.name
class WorkoutEquipment(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
exercise = models.ForeignKey(
Exercise,
on_delete=models.CASCADE,
related_name='workout_exercise_workout'
)
equipment = models.ForeignKey(
Equipment,
on_delete=models.CASCADE,
related_name='workout_exercise_workout'
)
def __str__(self):
return self.exercise.name + " : " + self.equipment.name