Created
February 25, 2017 12:46
-
-
Save hseritt/a0cf76e3dbe555939851c02ddccaf978 to your computer and use it in GitHub Desktop.
Django model class using upload directories with a date/time structure hierarchy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class ArticleAttachment(models.Model): | |
""" | |
Attached files for articles | |
""" | |
att_file = models.FileField( | |
upload_to='content/uploads/articles/%Y/%m/%d/%H/%M/%S') | |
class Meta: | |
verbose_name = 'Article Attachment' | |
verbose_name_plural = 'Article Attachments' | |
def __str__(self): | |
return os.path.basename(self.att_file.name) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment