Skip to content

Instantly share code, notes, and snippets.

@Nipun2016
Last active February 9, 2018 06:01
Show Gist options
  • Save Nipun2016/62f49627b41580c59f475e47e1a269d2 to your computer and use it in GitHub Desktop.
Save Nipun2016/62f49627b41580c59f475e47e1a269d2 to your computer and use it in GitHub Desktop.
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
class FileAttachment(models.Model):
content_type = models.ForeignKey(ContentType, related_name="content_type_timelines")
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
created = models.DateTimeField(_('created'), auto_now_add=True)
modified = models.DateTimeField(_('modified'), auto_now=True)
attachment_file = models.FileField(_('attachment'), upload_to=attachment_upload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment