Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
dbd99de6
Kaydet (Commit)
dbd99de6
authored
Nis 27, 2016
tarafından
Tobias McNulty
Kaydeden (comit)
Tim Graham
May 07, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26508 -- Clarified docs for various FieldFile methods.
üst
101dd787
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
5 deletions
+48
-5
file.txt
docs/ref/files/file.txt
+11
-0
fields.txt
docs/ref/models/fields.txt
+37
-5
No files found.
docs/ref/files/file.txt
Dosyayı görüntüle @
dbd99de6
...
@@ -31,6 +31,17 @@ The ``File`` class
...
@@ -31,6 +31,17 @@ The ``File`` class
The underlying :py:term:`file object` that this class wraps.
The underlying :py:term:`file object` that this class wraps.
.. admonition:: Be careful with this attribute in subclasses.
Some subclasses of :class:`File`, including
:class:`~django.core.files.base.ContentFile` and
:class:`~django.db.models.fields.files.FieldFile`, may replace this
attribute with an object other than a Python :py:term:`file object`.
In these cases, this attribute may itself be a :class:`File`
subclass (and not necessarily the same subclass). Whenever
possible, use the attributes and methods of the subclass itself
rather than the those of the subclass's ``file`` attribute.
.. attribute:: mode
.. attribute:: mode
The read/write mode for the file.
The read/write mode for the file.
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
dbd99de6
...
@@ -764,9 +764,36 @@ can change the maximum length using the :attr:`~CharField.max_length` argument.
...
@@ -764,9 +764,36 @@ can change the maximum length using the :attr:`~CharField.max_length` argument.
When you access a :class:`~django.db.models.FileField` on a model, you are
When you access a :class:`~django.db.models.FileField` on a model, you are
given an instance of :class:`FieldFile` as a proxy for accessing the underlying
given an instance of :class:`FieldFile` as a proxy for accessing the underlying
file. In addition to the functionality inherited from
file.
:class:`django.core.files.File`, this class has several attributes and methods
that can be used to interact with file data:
The API of :class:`FieldFile` mirrors that of :class:`~django.core.files.File`,
with one key difference: *The object wrapped by the class is not necessarily a
wrapper around Python's built-in file object.* Instead, it is a wrapper around
the result of the :attr:`Storage.open()<django.core.files.storage.Storage.open>`
method, which may be a :class:`~django.core.files.File` object, or it may be a
custom storage's implementation of the :class:`~django.core.files.File` API.
In addition to the API inherited from
:class:`~django.core.files.File` such as :meth:`~django.core.files.File.read`
and :meth:`~django.core.files.File.write`, :class:`FieldFile` includes several
methods that can be used to interact with the underlying file:
.. warning::
Two methods of this class, :meth:`~FieldFile.save` and
:meth:`~FieldFile.delete`, default to saving the model object of the
associated ``FieldFile`` in the database.
.. attribute:: FieldFile.name
The name of the file including the relative path from the root of the
:class:`~django.core.files.storage.Storage` of the associated
:class:`~django.db.models.FileField`.
.. attribute:: FieldFile.size
The result of the underlying :attr:`Storage.size()
<django.core.files.storage.Storage.size>` method.
.. attribute:: FieldFile.url
.. attribute:: FieldFile.url
...
@@ -776,8 +803,13 @@ A read-only property to access the file's relative URL by calling the
...
@@ -776,8 +803,13 @@ A read-only property to access the file's relative URL by calling the
.. method:: FieldFile.open(mode='rb')
.. method:: FieldFile.open(mode='rb')
Behaves like the standard Python ``open()`` method and opens the file
Opens or reopens the file associated with this instance in the specified
associated with this instance in the mode specified by ``mode``.
``mode``. Unlike the standard Python ``open()`` method, it doesn't return a
file descriptor.
Since the underlying file is opened implicitly when accessing it, it may be
unnecessary to call this method except to reset the pointer to the underlying
file or to change the ``mode``.
.. method:: FieldFile.close()
.. method:: FieldFile.close()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment