In home (views.py) how to display a list of all exercises (name and repetitions) linked to the same user Card?
models.py
class Card(models.Model):
user = models.OneToOneField(User)
trainer = models.ForeignKey(User, related_name='trainer')
def __unicode__(self):
return u'%s' % (self.id)
class Exercise(models.Model):
card = models.ForeignKey(Card)
name = models.CharField(max_length=50)
repetitions = models.IntegerField(default=0, blank=True, null=True)
def __unicode__(self):
return u'%s' % (self.name)
views.py
from django.http import HttpResponse
from django.contrib.auth.decorators import login_required
from cards.models import Card, Exercise
@login_required
def home(request):
user = request.user.get_full_name()
return HttpResponse("Welcome %s This is your home." % (user))