:py:mod:`oioioi.filetracker.fields` =================================== .. py:module:: oioioi.filetracker.fields Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: oioioi.filetracker.fields.FieldFile oioioi.filetracker.fields._FileDescriptor oioioi.filetracker.fields.FileField .. py:class:: FieldFile(instance, field, name) Bases: :py:obj:`django.db.models.fields.files.FieldFile` A mixin class used to forward file methods to an underlaying file object. The internal file object has to be called "file":: class FileProxy(FileProxyMixin): def __init__(self, file): self.file = file .. py:method:: read_using_cache() Opens a file using a cache (if it's possible) .. py:class:: _FileDescriptor(field) Bases: :py:obj:`django.db.models.fields.files.FileDescriptor` The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:: >>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size Assign a file object on assignment so you can do:: >>> with open('/path/to/hello.world') as f: ... instance.file = File(f) .. py:method:: __get__(instance=None, owner=None) Retrieve and caches the value from the datastore on the first lookup. Return the cached value. .. py:class:: FileField(*args, **kwargs) Bases: :py:obj:`django.db.models.fields.files.FileField` A :class:`~django.db.models.FileField` with fixtures support. Default value of max_length is increased from 100 to 255. Values of ``FileFields`` are serialized as:: data:: It is also possible to decode a more human-friendly representaion:: data::raw: but this works only for ASCII content. .. py:attribute:: descriptor_class .. py:attribute:: attr_class .. py:method:: get_prep_value(value) Perform preliminary non-db specific value checks and conversions. .. py:method:: value_to_string(obj) Return a string value of this field from the passed obj. This is used by the serialization framework.