Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7917205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:04:00+00:00 2026-06-03T15:04:00+00:00

I’m creating a tracking application for exercise and I’m wondering about the most efficient

  • 0

I’m creating a tracking application for exercise and I’m wondering about the most efficient way to create the models. Most exercises I do have repetitions, sets, and weights. But then there are runs which have distances and times. At first, I was going to create two different models to capture each, but then I thought it might be better to combine then. Now, I’m not sure.

Ok, below is my first pass:

LEVELS = (
    (1, '1 - Hardly'),
    (2, '2'),
    (3, '3'),
    (4, '4'),
    (5, '5 - Average'),
    (6, '6'),
    (7, '7'),
    (8, '8'),
    (9, '9'),
    (10, '10 - Very'),

class Jog(models.Model):
    distance = models.DecimalField("Distance (Miles)", max_digits=4, decimal_places=2)
    time = models.DecimalField("Time (Minutes)", max_digits=4, decimal_places=2)
    intensity = models.IntegerField("Intensity", choices = LEVELS, default = 5)
    date = models.DateTimeField("Date", blank=True, default=datetime.now)   
    notes = models.TextField("Notes", blank=True)

    def __str__(self):
        return "%s Miles in %s Minutes (Intensity of %s)" % (self.distance, self.time, self.intensity)

    class Meta:
        verbose_name = "Jog"

class Exercise_Type(models.Model):
    name = models.CharField("Exercise Name", max_length=200, unique = True)
    slug = models.SlugField(max_length=100, blank=True)
    notes = models.TextField("Notes", blank=True)

    def __str__(self):
        return self.name

class Workout(models.Model):
    exercise_type = models.ForeignKey(Exercise_Type, verbose_name="Exercise Type")
    reps = models.IntegerField("Repetitions")
    sets = models.DecimalField("Sets", max_digits=2, decimal_places=1)
    weight = models.IntegerField("Weight", blank=True, null=True)
    intensity = models.IntegerField("Intensity", choices = LEVELS, default = 5)
    date = models.DateTimeField("Date", blank=True, default=datetime.now)
    notes = models.TextField("Notes", blank=True)

This seemed silly though because a jog is a type of workout and is only getting split out because it has different measurement characteristics. So then I thought, what if I do something like this. Define the necessary fields in the workout type and then enable/suppress them by asking the user the Exercise Type:

class Exercise_Type(models.Model):
    name = models.CharField("Exercise Name", max_length=200, unique = True)
    slug = models.SlugField(max_length=100, blank=True)
    notes = models.TextField("Notes", blank=True)

    distance = models.BooleanField("Use Distance Field?", default = False)
    time = models.BooleanField("Use Time Field?", default = False)
    reps = models.BooleanField("Use Reps Field", default = False)
    sets = models.BooleanField("Use Sets Field?", default = False)
    weight = models.BooleanField("Use Weight Field?", default = False)

    def __str__(self):
        return self.name

class Workout(models.Model):
    exercise_type = models.ForeignKey(Exercise_Type, verbose_name="Exercise Type")
    distance = models.DecimalField("Distance (Miles)", max_digits=4, decimal_places=2, blank = True, null=True)
    time = models.DecimalField("Time (Minutes)", max_digits=4, decimal_places=2, blank = True, null=True)
    reps = models.IntegerField("Repetitions", blank = True, null=True)
    sets = models.DecimalField("Sets", max_digits=2, decimal_places=1, blank = True, null=True)
    weight = models.IntegerField("Weight", blank=True, null=True)
    intensity = models.IntegerField("Intensity", choices = LEVELS, default = 5)
    date = models.DateTimeField("Date", blank=True, default=datetime.now)
    notes = models.TextField("Notes", blank=True)

This seems like a waste of resources because every exercise will technically have every field regardless of whether it needs it or not.

Then I thought, what about sub-classing? That’s when I gave up and decided to appeal to those more knowledgeable than myself.

What’s the best way to organize this model?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:04:03+00:00Added an answer on June 3, 2026 at 3:04 pm

    Since each exercise has one or more properties that you want to measure, you should extract those properties out, so you end up with three main models.

    class Metric(models.Model):
       name = models.CharField(max_length=20)
       description = models.TextField(null=True, blank=True)
       measured_in = models.CharField(max_length=20, null=True, blank=True)
       # other fields
    
    class Measurement(models.Model):
       metric = models.ForeignKey(Metric)
       value = models.CharField(max_length=20, null=True, blank=True)
       workout_date = models.DateField(auto_now=True)
    
    class Workout(models.Model):
       # common attributes for each workout
       name = models.CharField(max_length=200)
       notes = models.TextField()
       metrics = models.ManyToManyField(Measurement)
    

    You add various metrics (things you measure) to Metric. For each workout, you identify which metric you want to track, by adding creating a new Measurement. Finally, you associate it to each workout when you create it.

    Here is a sample:

    reps = Metric.objects.create(name='Reps')
    my_reps = Measurement.objects.create(metric=reps,value=10)
    w = Workout(name="Weights")
    w.metrics.add(my_reps)
    w.save()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.