Skip to content

Instantly share code, notes, and snippets.

@MattTheRed
Created June 4, 2013 20:17
Show Gist options
  • Select an option

  • Save MattTheRed/5709186 to your computer and use it in GitHub Desktop.

Select an option

Save MattTheRed/5709186 to your computer and use it in GitHub Desktop.
class Face(models.Model):
photo = models.ImageField(upload_to=settings.MEDIA_ROOT)
frequency = models.IntegerField()
date_added = models.DateTimeField()
def __unicode__(self):
return self.photo.name
class FaceForm(ModelForm):
class Meta:
model = Face
exclude = ('date_added')
def save(self, commit=True):
face = super(FaceForm, self).save(commit=False)
face.date_added = datetime.datetime.now()
face.save()
return face
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment