instructor_name = models.CharField(max_length=255, blank=True, null=True)
instructor_email = models.EmailField(blank=True, null=True)
- updated_at = models.DateTimeField(default=datetime.datetime.utcnow)
+ # Save school name redundantly to speed filtering
+ school_name = models.CharField(max_length=255, blank=True, null=True)
+ updated_at = models.DateTimeField(default=datetime.datetime.utcnow)
created_at = models.DateTimeField(auto_now_add=True)
def save(self, *args, **kwargs):
""" Save school and generate a slug if one doesn't exist """
+ if self.school_name != self.school.name:
+ self.school_name = self.school.name
super(Course, self).save(*args, **kwargs) # generate a self.id
if not self.slug:
self.slug = defaultfilters.slugify("%s %s" % (self.name, self.id))