doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
i18n_patterns(*urls, prefix_default_language=True)
django.topics.i18n.translation#django.conf.urls.i18n.i18n_patterns
static.static(prefix, view=django.views.static.serve, **kwargs)
django.ref.urls#django.conf.urls.static.static
class GenericInlineModelAdmin The GenericInlineModelAdmin class inherits all properties from an InlineModelAdmin class. However, it adds a couple of its own for working with the generic relation: ct_field The name of the ContentType foreign key field on the model. Defaults to content_type. ct_fk_field The name of the integer field that represents the ID of the related object. Defaults to object_id.
django.ref.contrib.contenttypes#django.contrib.contenttypes.admin.GenericInlineModelAdmin
ct_field The name of the ContentType foreign key field on the model. Defaults to content_type.
django.ref.contrib.contenttypes#django.contrib.contenttypes.admin.GenericInlineModelAdmin.ct_field
ct_fk_field The name of the integer field that represents the ID of the related object. Defaults to object_id.
django.ref.contrib.contenttypes#django.contrib.contenttypes.admin.GenericInlineModelAdmin.ct_fk_field
class GenericStackedInline Subclasses of GenericInlineModelAdmin with stacked and tabular layouts, respectively.
django.ref.contrib.contenttypes#django.contrib.contenttypes.admin.GenericStackedInline
class GenericTabularInline
django.ref.contrib.contenttypes#django.contrib.contenttypes.admin.GenericTabularInline
class GenericForeignKey There are three parts to setting up a GenericForeignKey: Give your model a ForeignKey to ContentType. The usual name for this field is “content_type”. Give your model a field that can store primary key values from the models you’ll be relating to. For most models, this means a PositiveIntegerField. The usual name for this field is “object_id”. Give your model a GenericForeignKey, and pass it the names of the two fields described above. If these fields are named “content_type” and “object_id”, you can omit this – those are the default field names GenericForeignKey will look for. for_concrete_model If False, the field will be able to reference proxy models. Default is True. This mirrors the for_concrete_model argument to get_for_model().
django.ref.contrib.contenttypes#django.contrib.contenttypes.fields.GenericForeignKey
for_concrete_model If False, the field will be able to reference proxy models. Default is True. This mirrors the for_concrete_model argument to get_for_model().
django.ref.contrib.contenttypes#django.contrib.contenttypes.fields.GenericForeignKey.for_concrete_model
class GenericRelation related_query_name The relation on the related object back to this object doesn’t exist by default. Setting related_query_name creates a relation from the related object back to this one. This allows querying and filtering from the related object.
django.ref.contrib.contenttypes#django.contrib.contenttypes.fields.GenericRelation
related_query_name The relation on the related object back to this object doesn’t exist by default. Setting related_query_name creates a relation from the related object back to this one. This allows querying and filtering from the related object.
django.ref.contrib.contenttypes#django.contrib.contenttypes.fields.GenericRelation.related_query_name
class BaseGenericInlineFormSet
django.ref.contrib.contenttypes#django.contrib.contenttypes.forms.BaseGenericInlineFormSet
generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, validate_max=False, for_concrete_model=True, min_num=None, validate_min=False, absolute_max=None, can_delete_extra=True) Returns a GenericInlineFormSet using modelformset_factory(). You must provide ct_field and fk_field if they are different from the defaults, content_type and object_id respectively. Other parameters are similar to those documented in modelformset_factory() and inlineformset_factory(). The for_concrete_model argument corresponds to the for_concrete_model argument on GenericForeignKey. Changed in Django 3.2: The absolute_max and can_delete_extra arguments were added.
django.ref.contrib.contenttypes#django.contrib.contenttypes.forms.generic_inlineformset_factory
class ContentType Each instance of ContentType has two fields which, taken together, uniquely describe an installed model: app_label The name of the application the model is part of. This is taken from the app_label attribute of the model, and includes only the last part of the application’s Python import path; django.contrib.contenttypes, for example, becomes an app_label of contenttypes. model The name of the model class. Additionally, the following property is available: name The human-readable name of the content type. This is taken from the verbose_name attribute of the model.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentType
app_label The name of the application the model is part of. This is taken from the app_label attribute of the model, and includes only the last part of the application’s Python import path; django.contrib.contenttypes, for example, becomes an app_label of contenttypes.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentType.app_label
ContentType.get_object_for_this_type(**kwargs) Takes a set of valid lookup arguments for the model the ContentType represents, and does a get() lookup on that model, returning the corresponding object.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentType.get_object_for_this_type
model The name of the model class.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentType.model
ContentType.model_class() Returns the model class represented by this ContentType instance.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentType.model_class
name The human-readable name of the content type. This is taken from the verbose_name attribute of the model.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentType.name
class ContentTypeManager ContentType also has a custom manager, ContentTypeManager, which adds the following methods: clear_cache() Clears an internal cache used by ContentType to keep track of models for which it has created ContentType instances. You probably won’t ever need to call this method yourself; Django will call it automatically when it’s needed. get_for_id(id) Lookup a ContentType by ID. Since this method uses the same shared cache as get_for_model(), it’s preferred to use this method over the usual ContentType.objects.get(pk=id) get_for_model(model, for_concrete_model=True) Takes either a model class or an instance of a model, and returns the ContentType instance representing that model. for_concrete_model=False allows fetching the ContentType of a proxy model. get_for_models(*models, for_concrete_models=True) Takes a variadic number of model classes, and returns a dictionary mapping the model classes to the ContentType instances representing them. for_concrete_models=False allows fetching the ContentType of proxy models. get_by_natural_key(app_label, model) Returns the ContentType instance uniquely identified by the given application label and model name. The primary purpose of this method is to allow ContentType objects to be referenced via a natural key during deserialization.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentTypeManager
clear_cache() Clears an internal cache used by ContentType to keep track of models for which it has created ContentType instances. You probably won’t ever need to call this method yourself; Django will call it automatically when it’s needed.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentTypeManager.clear_cache
get_by_natural_key(app_label, model) Returns the ContentType instance uniquely identified by the given application label and model name. The primary purpose of this method is to allow ContentType objects to be referenced via a natural key during deserialization.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentTypeManager.get_by_natural_key
get_for_id(id) Lookup a ContentType by ID. Since this method uses the same shared cache as get_for_model(), it’s preferred to use this method over the usual ContentType.objects.get(pk=id)
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentTypeManager.get_for_id
get_for_model(model, for_concrete_model=True) Takes either a model class or an instance of a model, and returns the ContentType instance representing that model. for_concrete_model=False allows fetching the ContentType of a proxy model.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentTypeManager.get_for_model
get_for_models(*models, for_concrete_models=True) Takes a variadic number of model classes, and returns a dictionary mapping the model classes to the ContentType instances representing them. for_concrete_models=False allows fetching the ContentType of proxy models.
django.ref.contrib.contenttypes#django.contrib.contenttypes.models.ContentTypeManager.get_for_models
django.core.cache.cache As a shortcut, the default cache is available as django.core.cache.cache: >>> from django.core.cache import cache This object is equivalent to caches['default'].
django.topics.cache#django.core.cache.cache
django.core.cache.caches You can access the caches configured in the CACHES setting through a dict-like object: django.core.cache.caches. Repeated requests for the same alias in the same thread will return the same object. >>> from django.core.cache import caches >>> cache1 = caches['myalias'] >>> cache2 = caches['myalias'] >>> cache1 is cache2 True If the named key does not exist, InvalidCacheBackendError will be raised. To provide thread-safety, a different instance of the cache backend will be returned for each thread.
django.topics.cache#django.core.cache.caches
django.core.cache.utils.make_template_fragment_key(fragment_name, vary_on=None)
django.topics.cache#django.core.cache.utils.make_template_fragment_key
cache.add(key, value, timeout=DEFAULT_TIMEOUT, version=None)
django.topics.cache#django.core.caches.cache.add
cache.clear()
django.topics.cache#django.core.caches.cache.clear
cache.close()
django.topics.cache#django.core.caches.cache.close
cache.decr(key, delta=1, version=None)
django.topics.cache#django.core.caches.cache.decr
cache.delete(key, version=None)
django.topics.cache#django.core.caches.cache.delete
cache.delete_many(keys, version=None)
django.topics.cache#django.core.caches.cache.delete_many
cache.get(key, default=None, version=None) >>> cache.get('my_key') 'hello, world!'
django.topics.cache#django.core.caches.cache.get
cache.get_many(keys, version=None)
django.topics.cache#django.core.caches.cache.get_many
cache.get_or_set(key, default, timeout=DEFAULT_TIMEOUT, version=None)
django.topics.cache#django.core.caches.cache.get_or_set
cache.incr(key, delta=1, version=None)
django.topics.cache#django.core.caches.cache.incr
cache.set(key, value, timeout=DEFAULT_TIMEOUT, version=None) >>> cache.set('my_key', 'hello, world!', 30)
django.topics.cache#django.core.caches.cache.set
cache.set_many(dict, timeout)
django.topics.cache#django.core.caches.cache.set_many
cache.touch(key, timeout=DEFAULT_TIMEOUT, version=None)
django.topics.cache#django.core.caches.cache.touch
class CheckMessage(level, msg, hint=None, obj=None, id=None)
django.ref.checks#django.core.checks.CheckMessage
class Critical(msg, hint=None, obj=None, id=None)
django.ref.checks#django.core.checks.Critical
class Debug(msg, hint=None, obj=None, id=None)
django.ref.checks#django.core.checks.Debug
class Error(msg, hint=None, obj=None, id=None)
django.ref.checks#django.core.checks.Error
class Info(msg, hint=None, obj=None, id=None)
django.ref.checks#django.core.checks.Info
register(*tags)(function)
django.topics.checks#django.core.checks.register
class Warning(msg, hint=None obj=None, id=None)
django.ref.checks#django.core.checks.Warning
NON_FIELD_ERRORS
django.ref.exceptions#django.core.exceptions.NON_FIELD_ERRORS
class ContentFile(content, name=None) [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 django.core.files.base import ContentFile f1 = ContentFile("esta frase está en español") f2 = ContentFile(b"these are bytes")
django.ref.files.file#django.core.files.base.ContentFile
class File(file_object, name=None) [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 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. mode The read/write mode for the file. open(mode=None) [source] Open or reopen the file (which also does File.seek(0)). The mode argument allows the same values as Python’s built-in open(). When reopening a file, mode will override whatever mode the file was originally opened with; None means to reopen with the original mode. It can be used as a context manager, e.g. with file.open() as f:. __iter__() [source] Iterate over the file yielding one line at a time. 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. multiple_chunks(chunk_size=None) [source] Returns True if the file is large enough to require multiple chunks to access all of its content give some chunk_size. 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, readline, readlines, seek, tell, truncate, write, writelines, readable(), writable(), and seekable().
django.ref.files.file#django.core.files.File
__iter__() [source] Iterate over the file yielding one line at a time.
django.ref.files.file#django.core.files.File.__iter__
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.
django.ref.files.file#django.core.files.File.chunks
close() [source] Close the file.
django.ref.files.file#django.core.files.File.close
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.
django.ref.files.file#django.core.files.File.delete
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.
django.ref.files.file#django.core.files.File.file
mode The read/write mode for the file.
django.ref.files.file#django.core.files.File.mode
multiple_chunks(chunk_size=None) [source] Returns True if the file is large enough to require multiple chunks to access all of its content give some chunk_size.
django.ref.files.file#django.core.files.File.multiple_chunks
name The name of the file including the relative path from MEDIA_ROOT.
django.ref.files.file#django.core.files.File.name
open(mode=None) [source] Open or reopen the file (which also does File.seek(0)). The mode argument allows the same values as Python’s built-in open(). When reopening a file, mode will override whatever mode the file was originally opened with; None means to reopen with the original mode. It can be used as a context manager, e.g. with file.open() as f:.
django.ref.files.file#django.core.files.File.open
File.save(name, content, save=True) Saves a new file with the file name and contents provided. This will not replace the existing file, but will create a new file and update the object to point to it. If save is True, the model’s save() method will be called once the file is saved. That is, these two lines: >>> car.photo.save('myphoto.jpg', content, save=False) >>> car.save() are equivalent to: >>> car.photo.save('myphoto.jpg', content, save=True) Note that the content argument must be an instance of either File or of a subclass of File, such as ContentFile.
django.ref.files.file#django.core.files.File.save
size The size of the file in bytes.
django.ref.files.file#django.core.files.File.size
class ImageFile(file_object, name=None) [source] Django provides a built-in class specifically for images. django.core.files.images.ImageFile inherits all the attributes and methods of File, and additionally provides the following: width Width of the image in pixels. height Height of the image in pixels.
django.ref.files.file#django.core.files.images.ImageFile
height Height of the image in pixels.
django.ref.files.file#django.core.files.images.ImageFile.height
width Width of the image in pixels.
django.ref.files.file#django.core.files.images.ImageFile.width
_open(name, mode='rb')
django.howto.custom-file-storage#django.core.files.storage._open
_save(name, content)
django.howto.custom-file-storage#django.core.files.storage._save
class DefaultStorage DefaultStorage provides lazy access to the current default storage system as defined by DEFAULT_FILE_STORAGE. DefaultStorage uses get_storage_class() internally.
django.ref.files.storage#django.core.files.storage.DefaultStorage
class FileSystemStorage(location=None, base_url=None, file_permissions_mode=None, directory_permissions_mode=None) The FileSystemStorage class implements basic file storage on a local filesystem. It inherits from Storage and provides implementations for all the public methods thereof. location Absolute path to the directory that will hold the files. Defaults to the value of your MEDIA_ROOT setting. base_url URL that serves the files stored at this location. Defaults to the value of your MEDIA_URL setting. file_permissions_mode The file system permissions that the file will receive when it is saved. Defaults to FILE_UPLOAD_PERMISSIONS. directory_permissions_mode The file system permissions that the directory will receive when it is saved. Defaults to FILE_UPLOAD_DIRECTORY_PERMISSIONS. Note The FileSystemStorage.delete() method will not raise an exception if the given file name does not exist. get_created_time(name) Returns a datetime of the system’s ctime, i.e. os.path.getctime(). On some systems (like Unix), this is the time of the last metadata change, and on others (like Windows), it’s the creation time of the file.
django.ref.files.storage#django.core.files.storage.FileSystemStorage
base_url URL that serves the files stored at this location. Defaults to the value of your MEDIA_URL setting.
django.ref.files.storage#django.core.files.storage.FileSystemStorage.base_url
directory_permissions_mode The file system permissions that the directory will receive when it is saved. Defaults to FILE_UPLOAD_DIRECTORY_PERMISSIONS.
django.ref.files.storage#django.core.files.storage.FileSystemStorage.directory_permissions_mode
file_permissions_mode The file system permissions that the file will receive when it is saved. Defaults to FILE_UPLOAD_PERMISSIONS.
django.ref.files.storage#django.core.files.storage.FileSystemStorage.file_permissions_mode
get_created_time(name) Returns a datetime of the system’s ctime, i.e. os.path.getctime(). On some systems (like Unix), this is the time of the last metadata change, and on others (like Windows), it’s the creation time of the file.
django.ref.files.storage#django.core.files.storage.FileSystemStorage.get_created_time
location Absolute path to the directory that will hold the files. Defaults to the value of your MEDIA_ROOT setting.
django.ref.files.storage#django.core.files.storage.FileSystemStorage.location
get_alternative_name(file_root, file_ext)
django.howto.custom-file-storage#django.core.files.storage.get_alternative_name
get_available_name(name, max_length=None)
django.howto.custom-file-storage#django.core.files.storage.get_available_name
get_storage_class(import_path=None) Returns a class or module which implements the storage API. When called without the import_path parameter get_storage_class will return the current default storage system as defined by DEFAULT_FILE_STORAGE. If import_path is provided, get_storage_class will attempt to import the class or module from the given path and will return it if successful. An exception will be raised if the import is unsuccessful.
django.ref.files.storage#django.core.files.storage.get_storage_class
get_valid_name(name)
django.howto.custom-file-storage#django.core.files.storage.get_valid_name
class Storage The Storage class provides a standardized API for storing files, along with a set of default behaviors that all other storage systems can inherit or override as necessary. Note When methods return naive datetime objects, the effective timezone used will be the current value of os.environ['TZ']; note that this is usually set from Django’s TIME_ZONE. delete(name) Deletes the file referenced by name. If deletion is not supported on the target storage system this will raise NotImplementedError instead. exists(name) Returns True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file. get_accessed_time(name) Returns a datetime of the last accessed time of the file. For storage systems unable to return the last accessed time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone. get_alternative_name(file_root, file_ext) Returns an alternative filename based on the file_root and file_ext parameters, an underscore plus a random 7 character alphanumeric string is appended to the filename before the extension. get_available_name(name, max_length=None) Returns a filename based on the name parameter that’s free and available for new content to be written to on the target storage system. The length of the filename will not exceed max_length, if provided. If a free unique filename cannot be found, a SuspiciousFileOperation exception will be raised. If a file with name already exists, get_alternative_name() is called to obtain an alternative name. get_created_time(name) Returns a datetime of the creation time of the file. For storage systems unable to return the creation time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone. get_modified_time(name) Returns a datetime of the last modified time of the file. For storage systems unable to return the last modified time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone. get_valid_name(name) Returns a filename based on the name parameter that’s suitable for use on the target storage system. generate_filename(filename) Validates the filename by calling get_valid_name() and returns a filename to be passed to the save() method. The filename argument may include a path as returned by FileField.upload_to. In that case, the path won’t be passed to get_valid_name() but will be prepended back to the resulting name. The default implementation uses os.path operations. Override this method if that’s not appropriate for your storage. listdir(path) Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files. For storage systems that aren’t able to provide such a listing, this will raise a NotImplementedError instead. open(name, mode='rb') Opens the file given by name. Note that although the returned file is guaranteed to be a File object, it might actually be some subclass. In the case of remote file storage this means that reading/writing could be quite slow, so be warned. path(name) The local filesystem path where the file can be opened using Python’s standard open(). For storage systems that aren’t accessible from the local filesystem, this will raise NotImplementedError instead. save(name, content, max_length=None) Saves a new file using the storage system, preferably with the name specified. If there already exists a file with this name name, the storage system may modify the filename as necessary to get a unique name. The actual name of the stored file will be returned. The max_length argument is passed along to get_available_name(). The content argument must be an instance of django.core.files.File or a file-like object that can be wrapped in File. size(name) Returns the total size, in bytes, of the file referenced by name. For storage systems that aren’t able to return the file size this will raise NotImplementedError instead. url(name) Returns the URL where the contents of the file referenced by name can be accessed. For storage systems that don’t support access by URL this will raise NotImplementedError instead.
django.ref.files.storage#django.core.files.storage.Storage
delete(name) Deletes the file referenced by name. If deletion is not supported on the target storage system this will raise NotImplementedError instead.
django.ref.files.storage#django.core.files.storage.Storage.delete
exists(name) Returns True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
django.ref.files.storage#django.core.files.storage.Storage.exists
generate_filename(filename) Validates the filename by calling get_valid_name() and returns a filename to be passed to the save() method. The filename argument may include a path as returned by FileField.upload_to. In that case, the path won’t be passed to get_valid_name() but will be prepended back to the resulting name. The default implementation uses os.path operations. Override this method if that’s not appropriate for your storage.
django.ref.files.storage#django.core.files.storage.Storage.generate_filename
get_accessed_time(name) Returns a datetime of the last accessed time of the file. For storage systems unable to return the last accessed time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone.
django.ref.files.storage#django.core.files.storage.Storage.get_accessed_time
get_alternative_name(file_root, file_ext) Returns an alternative filename based on the file_root and file_ext parameters, an underscore plus a random 7 character alphanumeric string is appended to the filename before the extension.
django.ref.files.storage#django.core.files.storage.Storage.get_alternative_name
get_available_name(name, max_length=None) Returns a filename based on the name parameter that’s free and available for new content to be written to on the target storage system. The length of the filename will not exceed max_length, if provided. If a free unique filename cannot be found, a SuspiciousFileOperation exception will be raised. If a file with name already exists, get_alternative_name() is called to obtain an alternative name.
django.ref.files.storage#django.core.files.storage.Storage.get_available_name
get_created_time(name) Returns a datetime of the creation time of the file. For storage systems unable to return the creation time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone.
django.ref.files.storage#django.core.files.storage.Storage.get_created_time
get_modified_time(name) Returns a datetime of the last modified time of the file. For storage systems unable to return the last modified time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone.
django.ref.files.storage#django.core.files.storage.Storage.get_modified_time
get_valid_name(name) Returns a filename based on the name parameter that’s suitable for use on the target storage system.
django.ref.files.storage#django.core.files.storage.Storage.get_valid_name
listdir(path) Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files. For storage systems that aren’t able to provide such a listing, this will raise a NotImplementedError instead.
django.ref.files.storage#django.core.files.storage.Storage.listdir
open(name, mode='rb') Opens the file given by name. Note that although the returned file is guaranteed to be a File object, it might actually be some subclass. In the case of remote file storage this means that reading/writing could be quite slow, so be warned.
django.ref.files.storage#django.core.files.storage.Storage.open
path(name) The local filesystem path where the file can be opened using Python’s standard open(). For storage systems that aren’t accessible from the local filesystem, this will raise NotImplementedError instead.
django.ref.files.storage#django.core.files.storage.Storage.path
save(name, content, max_length=None) Saves a new file using the storage system, preferably with the name specified. If there already exists a file with this name name, the storage system may modify the filename as necessary to get a unique name. The actual name of the stored file will be returned. The max_length argument is passed along to get_available_name(). The content argument must be an instance of django.core.files.File or a file-like object that can be wrapped in File.
django.ref.files.storage#django.core.files.storage.Storage.save
size(name) Returns the total size, in bytes, of the file referenced by name. For storage systems that aren’t able to return the file size this will raise NotImplementedError instead.
django.ref.files.storage#django.core.files.storage.Storage.size
url(name) Returns the URL where the contents of the file referenced by name can be accessed. For storage systems that don’t support access by URL this will raise NotImplementedError instead.
django.ref.files.storage#django.core.files.storage.Storage.url
class InMemoryUploadedFile A file uploaded into memory (i.e. stream-to-memory). This class is used by the MemoryFileUploadHandler.
django.ref.files.uploads#django.core.files.uploadedfile.InMemoryUploadedFile
class TemporaryUploadedFile A file uploaded to a temporary location (i.e. stream-to-disk). This class is used by the TemporaryFileUploadHandler. In addition to the methods from UploadedFile, it has one additional method:
django.ref.files.uploads#django.core.files.uploadedfile.TemporaryUploadedFile
TemporaryUploadedFile.temporary_file_path() Returns the full path to the temporary uploaded file.
django.ref.files.uploads#django.core.files.uploadedfile.TemporaryUploadedFile.temporary_file_path
class UploadedFile
django.ref.files.uploads#django.core.files.uploadedfile.UploadedFile
UploadedFile.charset For text/* content-types, the character set (i.e. utf8) supplied by the browser. Again, “trust but verify” is the best policy here.
django.ref.files.uploads#django.core.files.uploadedfile.UploadedFile.charset
UploadedFile.chunks(chunk_size=None) A generator returning chunks of the file. If multiple_chunks() is True, you should use this method in a loop instead of read(). In practice, it’s often easiest to use chunks() all the time. Looping over chunks() instead of using read() ensures that large files don’t overwhelm your system’s memory.
django.ref.files.uploads#django.core.files.uploadedfile.UploadedFile.chunks