Tuesday, March 27, 2012

Re: Need help creating model.

I think the Foreign Key route is the way to go. After setting up the fields on both the Student and Point models and establishing the FK relationship between the two, you could write a table-level method that returned the number of corresponding Points.

On Tuesday, March 27, 2012 7:18:12 PM UTC-6, Zach wrote:
I have the following in my Student model. I am wanting to track the
date of each point given to each student. The idea would be so that I
could see not only how many points each student has, but also see the
date each point was given. In the future I want to see the trend of
each students' points.   How should I go about this? Should I use a
Foreign Key in another class. I am new to this so thanks for reading.


class Student(models.Model):

  CLASS_CHOICES = (
        (u'Yoga','Yoga'),
        (u'Spanish', 'Spanish'),
        (u'French', 'French'),
        (u'Dance', 'Dance'),
  )

  name = models.CharField(max_length=30)
  points = models.IntegerField(max_length=4)
  classname = models.CharField("Class Name",max_length=20, choices =
CLASS_CHOICES)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sV-KrZWV8KMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment