rezamalik15

Untitled

Jun 10th, 2024
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. from django.db import models
  2. import os #<==== import modul ini
  3.  
  4. # Create your models here.
  5.  
  6. class File(models.Model):
  7.     file = models.FileField(upload_to='files/')
  8.     filetype = models.CharField(max_length=5, null=True)
  9.     description = models.CharField(max_length=100)
  10.     created_at = models.DateTimeField(auto_now_add=True)
  11.  
  12.     def filename(self): #<==== tamhbahkan method baru
  13.         return os.path.basename(self.file.name)
Advertisement
Add Comment
Please, Sign In to add comment