django_auxilium.models.fields.files module¶
Collection of Django custom model field which have something to do with files
-
class
django_auxilium.models.fields.files.OriginalFilenameRandomFileField(*args, **kwargs)¶ Bases:
django_auxilium.models.fields.files.RandomFileNameWithFilenameFileFieldMixin,django.db.models.fields.files.FileField
-
class
django_auxilium.models.fields.files.OriginalFilenameRandomImageField(*args, **kwargs)¶ Bases:
django_auxilium.models.fields.files.RandomFileNameWithFilenameFileFieldMixin,django.db.models.fields.files.ImageField
-
class
django_auxilium.models.fields.files.RandomFileField(*args, **kwargs)¶ Bases:
django_auxilium.models.fields.files.RandomFileNameFileFieldMixin,django.db.models.fields.files.FileField
-
class
django_auxilium.models.fields.files.RandomFileFieldDeconstructMixin[source]¶ Bases:
objectMixin for random filename file mixins which implements Django’s
deconstructto be Django-migrations compatible
-
class
django_auxilium.models.fields.files.RandomFileNameFileFieldMixin(*args, **kwargs)[source]¶ Bases:
django_auxilium.models.fields.files.RandomFileFieldDeconstructMixinMixing for a custom
FileFieldwhich generates random filenameParameters: upload_to (str) – String where uploaded files should be saved. Within that directory, random filename will always be selected.
-
class
django_auxilium.models.fields.files.RandomFileNameWithFilenameFileFieldMixin(*args, **kwargs)[source]¶ Bases:
django_auxilium.models.fields.files.RandomFileFieldDeconstructMixinMixing for a custom
FileFieldwhich generates random filename and also stores original filenameParameters: - upload_to (str) – String where uploaded files should be saved. Within that directory, random filename will always be selected.
- filename_field (str) – Name of Django model field name where original filename should be stored
-
class
django_auxilium.models.fields.files.RandomImageField(*args, **kwargs)¶ Bases:
django_auxilium.models.fields.files.RandomFileNameFileFieldMixin,django.db.models.fields.files.ImageField
-
django_auxilium.models.fields.files.original_random_filename_upload_to(path, filename_field)[source]¶ Get
upload_tocompliant method which will always return a random filename however will also store the original filename in the model.Parameters: - path (str) – The path relative to
mediawhere the filaname should be uploaded to - filename_field (str) – The name of the model attribute to which the original filename should be stored.
Returns: upload_to – Django
FileField’supload_tocompliant functionReturn type: function
- path (str) – The path relative to
-
django_auxilium.models.fields.files.random_filename_upload_to(path)[source]¶ Get
upload_tocompliant method which will always return a random filename.This method can be used as Django’s
FileFieldupload_toparameter. It returns anupload_tocallable which will make sure the filename will always be random. This method also accepts apathparameter which will define where relative to the media folder, the file will be stored.Parameters: path (str) – The path relative to mediawhere the filename should be uploaded toReturns: upload_to – Django FileField’supload_tocompliant functionReturn type: function