Created
July 1, 2017 08:38
-
-
Save solanoize/af5e02ff8e14660aba329c0120beba11 to your computer and use it in GitHub Desktop.
Custom FileField Bawaan Django untuk Membatasi Jenis File Image dan Sizenya
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
| from .fields import ImageFieldRestrict | |
| class Photo(models.Model): | |
| user = models.ForeignKey('auth.User', related_name="user_photos") | |
| booklet = models.ForeignKey(Booklet, related_name="photos") | |
| about = models.CharField(max_length=100) | |
| pic = ImageFieldRestrict(upload_to='photo/%Y/%m/%d') | |
| created = models.DateTimeField(auto_now_add=True) | |
| def __str__(self): | |
| return self.booklet.title | |
| class Meta: | |
| ordering = ('-created',) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment