neulab/docprompting-conala huggingface dataset:
class Avg(expression, output_field=None, distinct=False, filter=None, default=None, **extra)  
Returns the mean value of the given expression, which must be numeric unless you specify a different output_field.  Default alias: <field>__avg
 Return type: float if input is int, otherwise same as input field, or output_field if supplied  Has one optional argument:  
distinct  
If distinct=True, Avg returns the mean value of unique values. This is the SQL equivalent of AVG(DISTINCT <field>). The default value is False.
distinct  
If distinct=True, Avg returns the mean value of unique values. This is the SQL equivalent of AVG(DISTINCT <field>). The default value is False.
BinaryField.max_length  
The maximum length (in bytes) of the field. The maximum length is enforced in Django’s validation using MaxLengthValidator.
CASCADE  
Cascade deletes. Django emulates the behavior of the SQL constraint ON DELETE CASCADE and also deletes the object containing the ForeignKey. Model.delete() isn’t called on related models, but the pre_delete and post_delete signals are sent for all deleted objects.
CharField.db_collation  
 New in Django 3.2.  Optional. The database collation name of the field.  Note Collation names are not standardized. As such, this will not be portable across multiple database backends.   Oracle Oracle supports collations only when the MAX_STRING_SIZE database initialization parameter is set to EXTENDED.
CharField.max_length  
Required. The maximum length (in characters) of the field. The max_length is enforced at the database level and in Django’s validation using MaxLengthValidator.  Note If you are writing an application that must be portable to multiple database backends, you should be aware that there are restrictions on max_length for some backends. Refer to the database backend notes for details.
class Count(expression, distinct=False, filter=None, **extra)  
Returns the number of objects that are related through the provided expression.  Default alias: <field>__count
 Return type: int
  Has one optional argument:  
distinct  
If distinct=True, the count will only include unique instances. This is the SQL equivalent of COUNT(DISTINCT <field>). The default value is False. 
  Note The default argument is not supported.
distinct  
If distinct=True, the count will only include unique instances. This is the SQL equivalent of COUNT(DISTINCT <field>). The default value is False.
CursorWrapper.callproc(procname, params=None, kparams=None)  
Calls a database stored procedure with the given name. A sequence (params) or dictionary (kparams) of input parameters may be provided. Most databases don’t support kparams. Of Django’s built-in backends, only Oracle supports it. For example, given this stored procedure in an Oracle database: CREATE PROCEDURE "TEST_PROCEDURE"(v_i INTEGER, v_text NVARCHAR2(10)) AS
    p_i INTEGER;
    p_text NVARCHAR2(10);
BEGIN
    p_i := v_i;
    p_text := v_text;
    ...
END;
 This will call it: with connection.cursor() as cursor:
    cursor.callproc('test_procedure', [1, 'test'])
class DateField(auto_now=False, auto_now_add=False, **options)
DateField.auto_now  
Automatically set the field to now every time the object is saved. Useful for “last-modified” timestamps. Note that the current date is always used; it’s not just a default value that you can override. The field is only automatically updated when calling Model.save(). The field isn’t updated when making updates to other fields in other ways such as QuerySet.update(), though you can specify a custom value for the field in an update like that.
DateField.auto_now_add  
Automatically set the field to now when the object is first created. Useful for creation of timestamps. Note that the current date is always used; it’s not just a default value that you can override. So even if you set a value for this field when creating the object, it will be ignored. If you want to be able to modify this field, set the following instead of auto_now_add=True:  For DateField: default=date.today - from datetime.date.today()
 For DateTimeField: default=timezone.now - from django.utils.timezone.now()
class DateTimeField(auto_now=False, auto_now_add=False, **options)
DecimalField.max_digits  
The maximum number of digits allowed in the number. Note that this number must be greater than or equal to decimal_places.
DO_NOTHING  
Take no action. If your database backend enforces referential integrity, this will cause an IntegrityError unless you manually add an SQL ON DELETE constraint to the database field.
asc(nulls_first=False, nulls_last=False)  
Returns the expression ready to be sorted in ascending order. nulls_first and nulls_last define how null values are sorted. See Using F() to sort null values for example usage.
contains_aggregate  
Tells Django that this expression contains an aggregate and that a GROUP BY clause needs to be added to the query.
contains_over_clause  
Tells Django that this expression contains a Window expression. It’s used, for example, to disallow window function expressions in queries that modify data.
convert_value(value, expression, connection)  
A hook allowing the expression to coerce value into a more appropriate type. expression is the same as self.
desc(nulls_first=False, nulls_last=False)  
Returns the expression ready to be sorted in descending order. nulls_first and nulls_last define how null values are sorted. See Using F() to sort null values for example usage.
empty_result_set_value  
 New in Django 4.0.  Tells Django which value should be returned when the expression is used to apply a function over an empty result set. Defaults to NotImplemented which forces the expression to be computed on the database.
filterable  
Tells Django that this expression can be referenced in QuerySet.filter(). Defaults to True.
get_group_by_cols(alias=None)  
Responsible for returning the list of columns references by this expression. get_group_by_cols() should be called on any nested expressions. F() objects, in particular, hold a reference to a column. The alias parameter will be None unless the expression has been annotated and is used for grouping.
get_source_expressions()  
Returns an ordered list of inner expressions. For example: >>> Sum(F('foo')).get_source_expressions()
[F('foo')]
relabeled_clone(change_map)  
Returns a clone (copy) of self, with any column aliases relabeled. Column aliases are renamed when subqueries are created. relabeled_clone() should also be called on any nested expressions and assigned to the clone. change_map is a dictionary mapping old aliases to new aliases. Example: def relabeled_clone(self, change_map):
    clone = copy.copy(self)
    clone.expression = self.expression.relabeled_clone(change_map)
    return clone
resolve_expression(query=None, allow_joins=True, reuse=None, summarize=False, for_save=False)  
Provides the chance to do any pre-processing or validation of the expression before it’s added to the query. resolve_expression() must also be called on any nested expressions. A copy() of self should be returned with any necessary transformations. query is the backend query implementation. allow_joins is a boolean that allows or denies the use of joins in the query. reuse is a set of reusable joins for multi-join scenarios. summarize is a boolean that, when True, signals that the query being computed is a terminal aggregate query. for_save is a boolean that, when True, signals that the query being executed is performing a create or update.
reverse_ordering()  
Returns self with any modifications required to reverse the sort order within an order_by call. As an example, an expression implementing NULLS LAST would change its value to be NULLS FIRST. Modifications are only required for expressions that implement sort order like OrderBy. This method is called when reverse() is called on a queryset.
set_source_expressions(expressions)  
Takes a list of expressions and stores them such that get_source_expressions() can return them.
window_compatible  
Tells Django that this expression can be used as the source expression in Window. Defaults to False.
class RowRange(start=None, end=None)  
 
frame_type  
This attribute is set to 'ROWS'.
class ValueRange(start=None, end=None)  
 
frame_type  
This attribute is set to 'RANGE'. 
 PostgreSQL has limited support for ValueRange and only supports use of the standard start and end points, such as CURRENT ROW and UNBOUNDED
FOLLOWING.
class Window(expression, partition_by=None, order_by=None, frame=None, output_field=None)  
 
filterable  
Defaults to False. The SQL standard disallows referencing window functions in the WHERE clause and Django raises an exception when constructing a QuerySet that would do that. 
  
template  
Defaults to %(expression)s OVER (%(window)s)'. If only the expression argument is provided, the window clause will be blank.
filterable  
Defaults to False. The SQL standard disallows referencing window functions in the WHERE clause and Django raises an exception when constructing a QuerySet that would do that.
template  
Defaults to %(expression)s OVER (%(window)s)'. If only the expression argument is provided, the window clause will be blank.
Field.auto_created  
Boolean flag that indicates if the field was automatically created, such as the OneToOneField used by model inheritance.
db_type(connection)  
Returns the database column data type for the Field, taking into account the connection. See Custom database types for usage in custom fields.
deconstruct()  
Returns a 4-tuple with enough information to recreate the field:  The name of the field on the model. The import path of the field (e.g. "django.db.models.IntegerField"). This should be the most portable version, so less specific may be better. A list of positional arguments. A dict of keyword arguments.  This method must be added to fields prior to 1.7 to migrate its data using Migrations.
description  
A verbose description of the field, e.g. for the django.contrib.admindocs application. The description can be of the form: description = _("String (up to %(max_length)s)")
 where the arguments are interpolated from the field’s __dict__.
descriptor_class  
A class implementing the descriptor protocol that is instantiated and assigned to the model instance attribute. The constructor must accept a single argument, the Field instance. Overriding this class attribute allows for customizing the get and set behavior.
formfield(form_class=None, choices_form_class=None, **kwargs)  
Returns the default django.forms.Field of this field for ModelForm. By default, if both form_class and choices_form_class are None, it uses CharField. If the field has choices and choices_form_class isn’t specified, it uses TypedChoiceField. See Specifying the form field for a model field for usage.
from_db_value(value, expression, connection)  
Converts a value as returned by the database to a Python object. It is the reverse of get_prep_value(). This method is not used for most built-in fields as the database backend already returns the correct Python type, or the backend itself does the conversion. expression is the same as self. See Converting values to Python objects for usage.  Note For performance reasons, from_db_value is not implemented as a no-op on fields which do not require it (all Django fields). Consequently you may not call super in your definition.
get_db_prep_save(value, connection)  
Same as the get_db_prep_value(), but called when the field value must be saved to the database. By default returns get_db_prep_value().
get_db_prep_value(value, connection, prepared=False)  
Converts value to a backend-specific value. By default it returns value if prepared=True and get_prep_value() if is False. See Converting query values to database values for usage.
get_internal_type()  
Returns a string naming this field for backend specific purposes. By default, it returns the class name. See Emulating built-in field types for usage in custom fields.
get_prep_value(value)  
value is the current value of the model’s attribute, and the method should return data in a format that has been prepared for use as a parameter in a query. See Converting Python objects to query values for usage.
Field.hidden  
Boolean flag that indicates if a field is used to back another non-hidden field’s functionality (e.g. the content_type and object_id fields that make up a GenericForeignKey). The hidden flag is used to distinguish what constitutes the public subset of fields on the model from all the fields on the model.  Note Options.get_fields() excludes hidden fields by default. Pass in include_hidden=True to return hidden fields in the results.
Field.is_relation  
Boolean flag that indicates if a field contains references to one or more other models for its functionality (e.g. ForeignKey, ManyToManyField, OneToOneField, etc.).
Field.many_to_many  
Boolean flag that is True if the field has a many-to-many relation; False otherwise. The only field included with Django where this is True is ManyToManyField.
Field.many_to_one  
Boolean flag that is True if the field has a many-to-one relation, such as a ForeignKey; False otherwise.
Field.model  
Returns the model on which the field is defined. If a field is defined on a superclass of a model, model will refer to the superclass, not the class of the instance.
Field.one_to_many  
Boolean flag that is True if the field has a one-to-many relation, such as a GenericRelation or the reverse of a ForeignKey; False otherwise.
Field.one_to_one  
Boolean flag that is True if the field has a one-to-one relation, such as a OneToOneField; False otherwise.
pre_save(model_instance, add)  
Method called prior to get_db_prep_save() to prepare the value before being saved (e.g. for DateField.auto_now). model_instance is the instance this field belongs to and add is whether the instance is being saved to the database for the first time. It should return the value of the appropriate attribute from model_instance for this field. The attribute name is in self.attname (this is set up by Field). See Preprocessing values before saving for usage.
rel_db_type(connection)  
Returns the database column data type for fields such as ForeignKey and OneToOneField that point to the Field, taking into account the connection. See Custom database types for usage in custom fields.
Field.related_model  
Points to the model the field relates to. For example, Author in ForeignKey(Author, on_delete=models.CASCADE). The related_model for a GenericForeignKey is always None.
to_python(value)  
Converts the value into the correct Python object. It acts as the reverse of value_to_string(), and is also called in clean(). See Converting values to Python objects for usage.
value_from_object(obj)  
Returns the field’s value for the given model instance. This method is often used by value_to_string().
value_to_string(obj)  
Converts obj to a string. Used to serialize the value of the field. See Converting field data for serialization for usage.
add(*objs, bulk=True, through_defaults=None)  
Adds the specified model objects to the related object set. Example: >>> b = Blog.objects.get(id=1)
>>> e = Entry.objects.get(id=234)
>>> b.entry_set.add(e) # Associates Entry e with Blog b.
 In the example above, in the case of a ForeignKey relationship, QuerySet.update() is used to perform the update. This requires the objects to already be saved. You can use the bulk=False argument to instead have the related manager perform the update by calling e.save(). Using add() with a many-to-many relationship, however, will not call any save() methods (the bulk argument doesn’t exist), but rather create the relationships using QuerySet.bulk_create(). If you need to execute some custom logic when a relationship is created, listen to the m2m_changed signal, which will trigger pre_add and post_add actions. Using add() on a relation that already exists won’t duplicate the relation, but it will still trigger signals. For many-to-many relationships add() accepts either model instances or field values, normally primary keys, as the *objs argument. Use the through_defaults argument to specify values for the new intermediate model instance(s), if needed. You can use callables as values in the through_defaults dictionary and they will be evaluated once before creating any intermediate instance(s).
clear(bulk=True)  
Removes all objects from the related object set: >>> b = Blog.objects.get(id=1)
>>> b.entry_set.clear()
 Note this doesn’t delete the related objects – it just disassociates them. Just like remove(), clear() is only available on ForeignKeys where null=True and it also accepts the bulk keyword argument. For many-to-many relationships, the bulk keyword argument doesn’t exist.
create(through_defaults=None, **kwargs)  
Creates a new object, saves it and puts it in the related object set. Returns the newly created object: >>> b = Blog.objects.get(id=1)
>>> e = b.entry_set.create(
...     headline='Hello',
...     body_text='Hi',
...     pub_date=datetime.date(2005, 1, 1)
... )

# No need to call e.save() at this point -- it's already been saved.
 This is equivalent to (but simpler than): >>> b = Blog.objects.get(id=1)
>>> e = Entry(
...     blog=b,
...     headline='Hello',
...     body_text='Hi',
...     pub_date=datetime.date(2005, 1, 1)
... )
>>> e.save(force_insert=True)
 Note that there’s no need to specify the keyword argument of the model that defines the relationship. In the above example, we don’t pass the parameter blog to create(). Django figures out that the new Entry object’s blog field should be set to b. Use the through_defaults argument to specify values for the new intermediate model instance, if needed. You can use callables as values in the through_defaults dictionary.
remove(*objs, bulk=True)  
Removes the specified model objects from the related object set: >>> b = Blog.objects.get(id=1)
>>> e = Entry.objects.get(id=234)
>>> b.entry_set.remove(e) # Disassociates Entry e from Blog b.
 Similar to add(), e.save() is called in the example above to perform the update. Using remove() with a many-to-many relationship, however, will delete the relationships using QuerySet.delete() which means no model save() methods are called; listen to the m2m_changed signal if you wish to execute custom code when a relationship is deleted. For many-to-many relationships remove() accepts either model instances or field values, normally primary keys, as the *objs argument. For ForeignKey objects, this method only exists if null=True. If the related field can’t be set to None (NULL), then an object can’t be removed from a relation without being added to another. In the above example, removing e from b.entry_set() is equivalent to doing e.blog = None, and because the blog ForeignKey doesn’t have null=True, this is invalid. For ForeignKey objects, this method accepts a bulk argument to control how to perform the operation. If True (the default), QuerySet.update() is used. If bulk=False, the save() method of each individual model instance is called instead. This triggers the pre_save and post_save signals and comes at the expense of performance. For many-to-many relationships, the bulk keyword argument doesn’t exist.
set(objs, bulk=True, clear=False, through_defaults=None)  
Replace the set of related objects: >>> new_list = [obj1, obj2, obj3]
>>> e.related_set.set(new_list)
 This method accepts a clear argument to control how to perform the operation. If False (the default), the elements missing from the new set are removed using remove() and only the new ones are added. If clear=True, the clear() method is called instead and the whole set is added at once. For ForeignKey objects, the bulk argument is passed on to add() and remove(). For many-to-many relationships, the bulk keyword argument doesn’t exist. Note that since set() is a compound operation, it is subject to race conditions. For instance, new objects may be added to the database in between the call to clear() and the call to add(). For many-to-many relationships set() accepts a list of either model instances or field values, normally primary keys, as the objs argument. Use the through_defaults argument to specify values for the new intermediate model instance(s), if needed. You can use callables as values in the through_defaults dictionary and they will be evaluated once before creating any intermediate instance(s).
FileField.storage  
A storage object, or a callable which returns a storage object. This handles the storage and retrieval of your files. See Managing files for details on how to provide this object.
FileField.upload_to  
This attribute provides a way of setting the upload directory and file name, and can be set in two ways. In both cases, the value is passed to the Storage.save() method. If you specify a string value or a Path, it may contain strftime() formatting, which will be replaced by the date/time of the file upload (so that uploaded files don’t fill up the given directory). For example: class MyModel(models.Model):
    # file will be uploaded to MEDIA_ROOT/uploads
    upload = models.FileField(upload_to='uploads/')
    # or...
    # file will be saved to MEDIA_ROOT/uploads/2015/01/30
    upload = models.FileField(upload_to='uploads/%Y/%m/%d/')
 If you are using the default FileSystemStorage, the string value will be appended to your MEDIA_ROOT path to form the location on the local filesystem where uploaded files will be stored. If you are using a different storage, check that storage’s documentation to see how it handles upload_to. upload_to may also be a callable, such as a function. This will be called to obtain the upload path, including the filename. This callable must accept two arguments and return a Unix-style path (with forward slashes) to be passed along to the storage system. The two arguments are:   
Argument Description   
instance 
An instance of the model where the FileField is defined. More specifically, this is the particular instance where the current file is being attached. In most cases, this object will not have been saved to the database yet, so if it uses the default AutoField, it might not yet have a value for its primary key field.   
filename The filename that was originally given to the file. This may or may not be taken into account when determining the final destination path.   For example: def user_directory_path(instance, filename):
    # file will be uploaded to MEDIA_ROOT/user_<id>/<filename>
    return 'user_{0}/{1}'.format(instance.user.id, filename)

class MyModel(models.Model):
    upload = models.FileField(upload_to=user_directory_path)
class FilePathField(path='', match=None, recursive=False, allow_files=True, allow_folders=False, max_length=100, **options)
FilePathField.allow_files  
Optional. Either True or False. Default is True. Specifies whether files in the specified location should be included. Either this or allow_folders must be True.
FilePathField.allow_folders  
Optional. Either True or False. Default is False. Specifies whether folders in the specified location should be included. Either this or allow_files must be True.
FilePathField.match  
Optional. A regular expression, as a string, that FilePathField will use to filter filenames. Note that the regex will be applied to the base filename, not the full path. Example: "foo.*\.txt$", which will match a file called foo23.txt but not bar.txt or foo23.png.
FilePathField.path  
Required. The absolute filesystem path to a directory from which this FilePathField should get its choices. Example: "/home/images". path may also be a callable, such as a function to dynamically set the path at runtime. Example: import os
from django.conf import settings
from django.db import models

def images_path():
    return os.path.join(settings.LOCAL_FILE_DIR, 'images')

class MyModel(models.Model):
    file = models.FilePathField(path=images_path)
FilePathField.recursive  
Optional. Either True or False. Default is False. Specifies whether all subdirectories of path should be included
class FilteredRelation(relation_name, *, condition=Q())  
 
relation_name  
The name of the field on which you’d like to filter the relation. 
  
condition  
A Q object to control the filtering.