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:
object
Mixin for random filename file mixins which implements Django’s
deconstruct
to be Django-migrations compatible
-
class
django_auxilium.models.fields.files.
RandomFileNameFileFieldMixin
(*args, **kwargs)[source]¶ Bases:
django_auxilium.models.fields.files.RandomFileFieldDeconstructMixin
Mixing for a custom
FileField
which 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.RandomFileFieldDeconstructMixin
Mixing for a custom
FileField
which 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_to
compliant 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
media
where 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_to
compliant functionReturn type: function
- path (str) – The path relative to
-
django_auxilium.models.fields.files.
random_filename_upload_to
(path)[source]¶ Get
upload_to
compliant method which will always return a random filename.This method can be used as Django’s
FileField
upload_to
parameter. It returns anupload_to
callable which will make sure the filename will always be random. This method also accepts apath
parameter which will define where relative to the media folder, the file will be stored.Parameters: path (str) – The path relative to media
where the filename should be uploaded toReturns: upload_to – Django FileField
’supload_to
compliant functionReturn type: function