Skip to content

Instantly share code, notes, and snippets.

@mjtamlyn
Created August 29, 2012 11:19
Show Gist options
  • Select an option

  • Save mjtamlyn/3510972 to your computer and use it in GitHub Desktop.

Select an option

Save mjtamlyn/3510972 to your computer and use it in GitHub Desktop.
from django.db import models
class Entry(models.Model):
RATING_CHOICES = zip(range(1, 11), range(1, 11))
user = models.ForeignKey('auth.User')
date = models.DateField()
medication_taken = models.BooleanField()
rating_1 = models.IntegerField(choices=RATING_CHOICES)
rating_2 = models.IntegerField(choices=RATING_CHOICES)
rating_3 = models.IntegerField(choices=RATING_CHOICES)
rating_4 = models.IntegerField(choices=RATING_CHOICES)
rating_5 = models.IntegerField(choices=RATING_CHOICES)
rating_6 = models.IntegerField(choices=RATING_CHOICES)
tags = models.ManyToManyField('mood_diary.Tag')
def __unicode__(self):
return 'Mood diary entry for %s on %s' % (self.user, self.date)
class Tag(models.Model):
name = models.CharField(max_length=255)
def __unicode__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment