- Author:
- junaidmgithub
- Posted:
- May 20, 2022
- Language:
- Python
- Version:
- 3.2
- Score:
- 0 (after 0 ratings)
FileField having auto upload_to path
1 2 3 4 5 6 7 8 9 10 | class FileField(models.FileField): def __init__(self, *args, **kwargs): assert not "upload_to" in kwargs kwargs["upload_to"] = self.get_upload_path super(FileField, self).__init__(*args, **kwargs) def get_upload_path(self, instance, filename): return os.path.join("_".join([ instance._meta.app_label, instance._meta.object_name, self.name]), filename).lower() |
More like this
- get_object_or_none by azwdevops 1 month, 1 week ago
- Mask sensitive data from logger by agusmakmun 3 months ago
- Template tag - list punctuation for a list of items by shapiromatron 1 year, 5 months ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 1 year, 5 months ago
- Serializer factory with Django Rest Framework by julio 2 years ago
Comments
Please login first before commenting.