neulab/docprompting-conala huggingface dataset:
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.
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.
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.
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.
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.
name  
The human-readable name of the content type. This is taken from the verbose_name attribute of the model.
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.
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_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.
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.
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.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.core.cache.utils.make_template_fragment_key(fragment_name, vary_on=None)
cache.get(key, default=None, version=None)  
>>> cache.get('my_key')
'hello, world!'
cache.get_or_set(key, default, timeout=DEFAULT_TIMEOUT, version=None)
cache.set(key, value, timeout=DEFAULT_TIMEOUT, version=None)  
>>> cache.set('my_key', 'hello, world!', 30)
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")
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().
__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.
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.
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.
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.
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:.
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.
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.
class DefaultStorage  
DefaultStorage provides lazy access to the current default storage system as defined by DEFAULT_FILE_STORAGE. DefaultStorage uses get_storage_class() internally.
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.
base_url  
URL that serves the files stored at this location. Defaults to the value of your MEDIA_URL setting.
directory_permissions_mode  
The file system permissions that the directory will receive when it is saved. Defaults to FILE_UPLOAD_DIRECTORY_PERMISSIONS.
file_permissions_mode  
The file system permissions that the file will receive when it is saved. Defaults to FILE_UPLOAD_PERMISSIONS.
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.
location  
Absolute path to the directory that will hold the files. Defaults to the value of your MEDIA_ROOT setting.
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.
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.
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.
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.
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.
class InMemoryUploadedFile  
A file uploaded into memory (i.e. stream-to-memory). This class is used by the MemoryFileUploadHandler.
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:
TemporaryUploadedFile.temporary_file_path()  
Returns the full path to the temporary uploaded file.
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.
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.
UploadedFile.content_type  
The content-type header uploaded with the file (e.g. text/plain or application/pdf). Like any data supplied by the user, you shouldn’t trust that the uploaded file is actually this type. You’ll still need to validate that the file contains the content that the content-type header claims – “trust but verify.”
UploadedFile.content_type_extra  
A dictionary containing extra parameters passed to the content-type header. This is typically provided by services, such as Google App Engine, that intercept and handle file uploads on your behalf. As a result your handler may not receive the uploaded file content, but instead a URL or other pointer to the file (see RFC 2388).
UploadedFile.multiple_chunks(chunk_size=None)  
Returns True if the uploaded file is big enough to require reading in multiple chunks. By default this will be any file larger than 2.5 megabytes, but that’s configurable; see below.
UploadedFile.name  
The name of the uploaded file (e.g. my_file.txt).
UploadedFile.read()  
Read the entire uploaded data from the file. Be careful with this method: if the uploaded file is huge it can overwhelm your system if you try to read it into memory. You’ll probably want to use chunks() instead; see below.
FileUploadHandler.chunk_size  
Size, in bytes, of the “chunks” Django should store into memory and feed into the handler. That is, this attribute controls the size of chunks fed into FileUploadHandler.receive_data_chunk. For maximum performance the chunk sizes should be divisible by 4 and should not exceed 2 GB (231 bytes) in size. When there are multiple chunk sizes provided by multiple handlers, Django will use the smallest chunk size defined by any handler. The default is 64*210 bytes, or 64 KB.
FileUploadHandler.file_complete(file_size)  
Called when a file has finished uploading. The handler should return an UploadedFile object that will be stored in request.FILES. Handlers may also return None to indicate that the UploadedFile object should come from subsequent upload handlers.
FileUploadHandler.handle_raw_input(input_data, META, content_length, boundary, encoding)  
Allows the handler to completely override the parsing of the raw HTTP input. input_data is a file-like object that supports read()-ing. META is the same object as request.META. content_length is the length of the data in input_data. Don’t read more than content_length bytes from input_data. boundary is the MIME boundary for this request. encoding is the encoding of the request. Return None if you want upload handling to continue, or a tuple of (POST, FILES) if you want to return the new data structures suitable for the request directly.
FileUploadHandler.new_file(field_name, file_name, content_type, content_length, charset, content_type_extra)  
Callback signaling that a new file upload is starting. This is called before any data has been fed to any upload handlers. field_name is a string name of the file <input> field. file_name is the filename provided by the browser. content_type is the MIME type provided by the browser – E.g. 'image/jpeg'. content_length is the length of the image given by the browser. Sometimes this won’t be provided and will be None. charset is the character set (i.e. utf8) given by the browser. Like content_length, this sometimes won’t be provided. content_type_extra is extra information about the file from the content-type header. See UploadedFile.content_type_extra. This method may raise a StopFutureHandlers exception to prevent future handlers from handling this file.
FileUploadHandler.receive_data_chunk(raw_data, start)  
Receives a “chunk” of data from the file upload. raw_data is a bytestring containing the uploaded data. start is the position in the file where this raw_data chunk begins. The data you return will get fed into the subsequent upload handlers’ receive_data_chunk methods. In this way, one handler can be a “filter” for other handlers. Return None from receive_data_chunk to short-circuit remaining upload handlers from getting this chunk. This is useful if you’re storing the uploaded data yourself and don’t want future handlers to store a copy of the data. If you raise a StopUpload or a SkipFile exception, the upload will abort or the file will be completely skipped.
FileUploadHandler.upload_complete()  
Callback signaling that the entire upload (all files) has completed.
FileUploadHandler.upload_interrupted()  
 New in Django 3.2.  Callback signaling that the upload was interrupted, e.g. when the user closed their browser during file upload.
class backends.smtp.EmailBackend(host=None, port=None, username=None, password=None, use_tls=None, fail_silently=False, use_ssl=None, timeout=None, ssl_keyfile=None, ssl_certfile=None, **kwargs)  
This is the default backend. Email will be sent through a SMTP server. The value for each argument is retrieved from the matching setting if the argument is None:  
host: EMAIL_HOST
 
port: EMAIL_PORT
 
username: EMAIL_HOST_USER
 
password: EMAIL_HOST_PASSWORD
 
use_tls: EMAIL_USE_TLS
 
use_ssl: EMAIL_USE_SSL
 
timeout: EMAIL_TIMEOUT
 
ssl_keyfile: EMAIL_SSL_KEYFILE
 
ssl_certfile: EMAIL_SSL_CERTFILE
  The SMTP backend is the default configuration inherited by Django. If you want to specify it explicitly, put the following in your settings: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
 If unspecified, the default timeout will be the one provided by socket.getdefaulttimeout(), which defaults to None (no timeout).
get_connection(backend=None, fail_silently=False, *args, **kwargs)
mail_admins(subject, message, fail_silently=False, connection=None, html_message=None)
mail_managers(subject, message, fail_silently=False, connection=None, html_message=None)
send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, html_message=None)
send_mass_mail(datatuple, fail_silently=False, auth_user=None, auth_password=None, connection=None)
AppCommand.handle_app_config(app_config, **options)  
Perform the command’s actions for app_config, which will be an AppConfig instance corresponding to an application label given on the command line.