I'm building a Django app that needs to store multiple selected dates for an event. The first thing that came to mind was build the event model:
class Event(models.Model):
title = models.CharField(max_length=200)
creator = models.ForeignKey(User)
modified = models.DateTimeField(auto_now=True, auto_now_add=False)
created = models.DateTimeField(auto_now=False, auto_now_add=True)
def __unicode__(self):
return self.title
class Meta:
ordering = ('title',)
Then build a separate table of EventDates:
class EventDate(models.Model):
event = models.ForeignKey(Event)
date = models.DateField()
modified = models.DateTimeField(auto_now=True, auto_now_add=False)
created = models.DateTimeField(auto_now=False, auto_now_add=True)
def __unicode__(self):
return "%s / %s" % (self.event, self.date)
class Meta:
ordering = ('created',)
But is this the best way? Is there a better performing alternative, like a comma separated string?