Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Prepopulation: Calling a field from another class [RSS Feed]

#1 Jan. 23, 2011 03:56:02

Mark P.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Prepopulation: Calling a field from another class

The idea I'm trying to wrap my head around is this... the exercise db
has just id, name each "workout" can have an exercise with different
sets, reps, etc... the workout_name field I want prepopulated so it
gets the exercise name that I choose from the selector then the sets,
reps, then time so if:
exercise: id=1, name=bench press
workout could be:
sets:1, reps:5,rest:45

I'd want the "workout_name" prepopulated with "bench-press-1-5-45"
upon filling in the fields on the workout add form and selecting the
exercise (foreignkey).

Eeessh does that make sense?


class Exercise(models.Model):
name = models.CharField(max_length=128, blank=False)

def __str__(self):
return (self.name)

class Workout(models.Model):
workout_name = models.CharField(max_length=128, blank=False)
exercise = models.ForeignKey(Exercise)
sets = models.IntegerField(max_length=2)
reps = models.IntegerField(max_length=2)
pause = models.IntegerField(max_length=3)


class WorkoutAdmin(admin.ModelAdmin):
prepopulated_fields = {"workout_name": (###This is where i'd
prepopulate my selection from class Exercise.name, "sets", "reps",

You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.


  • Root
  • » Django
  • » Prepopulation: Calling a field from another class [RSS Feed]

Board footer

Moderator control

Enjoy the 27th of May

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support