core.files.File.mode

mode The read/write mode for the file.

core.files.File.file

file The underlying file object that this class wraps. Be careful with this attribute in subclasses. Some subclasses of File, including ContentFile and FieldFile, may replace this attribute with an object other than a Python file object. In these cases, this attribute may itself be a 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.

core.files.File.delete()

File.delete(save=True) Removes the file from the model instance and deletes the underlying file. If save is True, the model’s save() method will be called once the file is deleted.

core.files.File.close()

close() [source] Close the file. In addition to the listed methods, File exposes the following attributes and methods of its file object: encoding, fileno, flush, isatty, newlines, read, readinto, readlines, seek, softspace, tell, truncate, writelines, xreadlines. If you are using Python 3, the seekable method is also available. Changed in Django 1.9: The seekable method was added.

core.files.File.chunks()

chunks(chunk_size=None) [source] Iterate over the file yielding “chunks” of a given size. chunk_size defaults to 64 KB. This is especially useful with very large files since it allows them to be streamed off disk and avoids storing the whole file in memory.

core.files.File

class File(file_object) [source] The File class is a thin wrapper around a Python file object with some Django-specific additions. Internally, Django uses this class when it needs to represent a file. File objects have the following attributes and methods: name The name of the file including the relative path from MEDIA_ROOT. size The size of the file in bytes. file The underlying file object that this class wraps. Be careful with this attribute in subclasses. Some subclasses

core.files.base.ContentFile

class ContentFile(File) [source] The ContentFile class inherits from File, but unlike File it operates on string content (bytes also supported), rather than an actual file. For example: from __future__ import unicode_literals from django.core.files.base import ContentFile f1 = ContentFile("esta sentencia está en español") f2 = ContentFile(b"these are bytes")

core.checks.Warning

class Warning(msg, hint=None obj=None, id=None) [source]

core.checks.register()

register(*tags)(function) You can pass as many tags to register as you want in order to label your check. Tagging checks is useful since it allows you to run only a certain group of checks. For example, to register a compatibility check, you would make the following call: from django.core.checks import register, Tags @register(Tags.compatibility) def my_check(app_configs, **kwargs): # ... perform compatibility checks and collect errors return errors You can register “deployment che

core.checks.Info

class Info(msg, hint=None, obj=None, id=None) [source]