doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
class URLValidator(schemes=None, regex=None, message=None, code=None)
A RegexValidator subclass that ensures a value looks like a URL, and raises an error code of 'invalid' if it doesn’t. Loopback addresses and reserved IP spaces are considered valid. Literal IPv6 addresses (RFC 3986#section-3.2.2) and Unicode domain... | django.ref.validators#django.core.validators.URLValidator |
schemes
URL/URI scheme list to validate against. If not provided, the default list is ['http', 'https', 'ftp', 'ftps']. As a reference, the IANA website provides a full list of valid URI schemes. | django.ref.validators#django.core.validators.URLValidator.schemes |
validate_comma_separated_integer_list
A RegexValidator instance that ensures a value is a comma-separated list of integers. | django.ref.validators#django.core.validators.validate_comma_separated_integer_list |
validate_email
An EmailValidator instance without any customizations. | django.ref.validators#django.core.validators.validate_email |
validate_image_file_extension
Uses Pillow to ensure that value.name (value is a File) has a valid image extension. | django.ref.validators#django.core.validators.validate_image_file_extension |
validate_ipv46_address
Uses both validate_ipv4_address and validate_ipv6_address to ensure a value is either a valid IPv4 or IPv6 address. | django.ref.validators#django.core.validators.validate_ipv46_address |
validate_ipv4_address
A RegexValidator instance that ensures a value looks like an IPv4 address. | django.ref.validators#django.core.validators.validate_ipv4_address |
validate_ipv6_address
Uses django.utils.ipv6 to check the validity of an IPv6 address. | django.ref.validators#django.core.validators.validate_ipv6_address |
validate_slug
A RegexValidator instance that ensures a value consists of only letters, numbers, underscores or hyphens. | django.ref.validators#django.core.validators.validate_slug |
validate_unicode_slug
A RegexValidator instance that ensures a value consists of only Unicode letters, numbers, underscores, or hyphens. | django.ref.validators#django.core.validators.validate_unicode_slug |
Databases Django officially supports the following databases: PostgreSQL MariaDB MySQL Oracle SQLite There are also a number of database backends provided by third parties. Django attempts to support as many features as possible on all database backends. However, not all database backends are alike, and we’ve had to ... | django.ref.databases |
execute_wrapper(wrapper) | django.topics.db.instrumentation#django.db.backends.base.DatabaseWrapper.execute_wrapper |
class BaseDatabaseSchemaEditor | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor |
BaseDatabaseSchemaEditor.add_constraint(model, constraint) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.add_constraint |
BaseDatabaseSchemaEditor.add_field(model, field) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.add_field |
BaseDatabaseSchemaEditor.add_index(model, index) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.add_index |
BaseDatabaseSchemaEditor.alter_db_table(model, old_db_table, new_db_table) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.alter_db_table |
BaseDatabaseSchemaEditor.alter_db_tablespace(model, old_db_tablespace, new_db_tablespace) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.alter_db_tablespace |
BaseDatabaseSchemaEditor.alter_field(model, old_field, new_field, strict=False) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.alter_field |
BaseDatabaseSchemaEditor.alter_index_together(model, old_index_together, new_index_together) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.alter_index_together |
BaseDatabaseSchemaEditor.alter_unique_together(model, old_unique_together, new_unique_together) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.alter_unique_together |
BaseDatabaseSchemaEditor.create_model(model) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.create_model |
BaseDatabaseSchemaEditor.delete_model(model) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.delete_model |
BaseDatabaseSchemaEditor.execute(sql, params=()) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.execute |
BaseDatabaseSchemaEditor.remove_constraint(model, constraint) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.remove_constraint |
BaseDatabaseSchemaEditor.remove_field(model, field) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.remove_field |
BaseDatabaseSchemaEditor.remove_index(model, index) | django.ref.schema-editor#django.db.backends.base.schema.BaseDatabaseSchemaEditor.remove_index |
SchemaEditor.connection | django.ref.schema-editor#django.db.backends.base.schema.SchemaEditor.connection |
django.db.backends.signals.connection_created | django.ref.signals#django.db.backends.signals.connection_created |
create_test_db(verbosity=1, autoclobber=False, serialize=True, keepdb=False)
Creates a new test database and runs migrate against it. verbosity has the same behavior as in run_tests(). autoclobber describes the behavior that will occur if a database with the same name as the test database is discovered: If autoclobb... | django.topics.testing.advanced#django.db.connection.creation.create_test_db |
destroy_test_db(old_database_name, verbosity=1, keepdb=False)
Destroys the database whose name is the value of NAME in DATABASES, and sets NAME to the value of old_database_name. The verbosity argument has the same behavior as for DiscoverRunner. If the keepdb argument is True, then the connection to the database wil... | django.topics.testing.advanced#django.db.connection.creation.destroy_test_db |
Migration.initial | django.topics.migrations#django.db.migrations.Migration.initial |
class AddConstraint(model_name, constraint) | django.ref.migration-operations#django.db.migrations.operations.AddConstraint |
class AddField(model_name, name, field, preserve_default=True) | django.ref.migration-operations#django.db.migrations.operations.AddField |
class AddIndex(model_name, index) | django.ref.migration-operations#django.db.migrations.operations.AddIndex |
class AlterField(model_name, name, field, preserve_default=True) | django.ref.migration-operations#django.db.migrations.operations.AlterField |
class AlterIndexTogether(name, index_together) | django.ref.migration-operations#django.db.migrations.operations.AlterIndexTogether |
class AlterModelManagers(name, managers) | django.ref.migration-operations#django.db.migrations.operations.AlterModelManagers |
class AlterModelOptions(name, options) | django.ref.migration-operations#django.db.migrations.operations.AlterModelOptions |
class AlterModelTable(name, table) | django.ref.migration-operations#django.db.migrations.operations.AlterModelTable |
class AlterOrderWithRespectTo(name, order_with_respect_to) | django.ref.migration-operations#django.db.migrations.operations.AlterOrderWithRespectTo |
class AlterUniqueTogether(name, unique_together) | django.ref.migration-operations#django.db.migrations.operations.AlterUniqueTogether |
class CreateModel(name, fields, options=None, bases=None, managers=None) | django.ref.migration-operations#django.db.migrations.operations.CreateModel |
class DeleteModel(name) | django.ref.migration-operations#django.db.migrations.operations.DeleteModel |
class RemoveConstraint(model_name, name) | django.ref.migration-operations#django.db.migrations.operations.RemoveConstraint |
class RemoveField(model_name, name) | django.ref.migration-operations#django.db.migrations.operations.RemoveField |
class RemoveIndex(model_name, name) | django.ref.migration-operations#django.db.migrations.operations.RemoveIndex |
class RenameField(model_name, old_name, new_name) | django.ref.migration-operations#django.db.migrations.operations.RenameField |
class RenameModel(old_name, new_name) | django.ref.migration-operations#django.db.migrations.operations.RenameModel |
class RunPython(code, reverse_code=None, atomic=None, hints=None, elidable=False) | django.ref.migration-operations#django.db.migrations.operations.RunPython |
class RunSQL(sql, reverse_sql=None, state_operations=None, hints=None, elidable=False) | django.ref.migration-operations#django.db.migrations.operations.RunSQL |
RunSQL.noop
Pass the RunSQL.noop attribute to sql or reverse_sql when you want the operation not to do anything in the given direction. This is especially useful in making the operation reversible. | django.ref.migration-operations#django.db.migrations.operations.RunSQL.noop |
class SeparateDatabaseAndState(database_operations=None, state_operations=None) | django.ref.migration-operations#django.db.migrations.operations.SeparateDatabaseAndState |
class Aggregate(*expressions, output_field=None, distinct=False, filter=None, default=None, **extra)
template
A class attribute, as a format string, that describes the SQL that is generated for this aggregate. Defaults to '%(function)s(%(distinct)s%(expressions)s)'.
function
A class attribute describing the... | django.ref.models.expressions#django.db.models.Aggregate |
allow_distinct
A class attribute determining whether or not this aggregate function allows passing a distinct keyword argument. If set to False (default), TypeError is raised if distinct=True is passed. | django.ref.models.expressions#django.db.models.Aggregate.allow_distinct |
empty_result_set_value
New in Django 4.0. Override empty_result_set_value to None since most aggregate functions result in NULL when applied to an empty result set. | django.ref.models.expressions#django.db.models.Aggregate.empty_result_set_value |
function
A class attribute describing the aggregate function that will be generated. Specifically, the function will be interpolated as the function placeholder within template. Defaults to None. | django.ref.models.expressions#django.db.models.Aggregate.function |
template
A class attribute, as a format string, that describes the SQL that is generated for this aggregate. Defaults to '%(function)s(%(distinct)s%(expressions)s)'. | django.ref.models.expressions#django.db.models.Aggregate.template |
window_compatible
Defaults to True since most aggregate functions can be used as the source expression in Window. | django.ref.models.expressions#django.db.models.Aggregate.window_compatible |
as_sql(compiler, connection)
Generates the SQL fragment for the expression. Returns a tuple (sql, params), where sql is the SQL string, and params is the list or tuple of query parameters. The compiler is an SQLCompiler object, which has a compile() method that can be used to compile other expressions. The connection... | django.ref.models.lookups#django.db.models.as_sql |
as_vendorname(compiler, connection)
Works like as_sql() method. When an expression is compiled by compiler.compile(), Django will first try to call as_vendorname(), where vendorname is the vendor name of the backend used for executing the query. The vendorname is one of postgresql, oracle, sqlite, or mysql for Django... | django.ref.models.lookups#django.db.models.as_vendorname |
class AutoField(**options) | django.ref.models.fields#django.db.models.AutoField |
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_fie... | django.ref.models.querysets#django.db.models.Avg |
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. | django.ref.models.querysets#django.db.models.Avg.distinct |
class BigAutoField(**options) | django.ref.models.fields#django.db.models.BigAutoField |
class BigIntegerField(**options) | django.ref.models.fields#django.db.models.BigIntegerField |
class BinaryField(max_length=None, **options) | django.ref.models.fields#django.db.models.BinaryField |
BinaryField.max_length
The maximum length (in bytes) of the field. The maximum length is enforced in Django’s validation using MaxLengthValidator. | django.ref.models.fields#django.db.models.BinaryField.max_length |
class BooleanField(**options) | django.ref.models.fields#django.db.models.BooleanField |
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. | django.ref.models.fields#django.db.models.CASCADE |
class CharField(max_length=None, **options) | django.ref.models.fields#django.db.models.CharField |
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 t... | django.ref.models.fields#django.db.models.CharField.db_collation |
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 restrict... | django.ref.models.fields#django.db.models.CharField.max_length |
class CheckConstraint(*, check, name)
Creates a check constraint in the database. | django.ref.models.constraints#django.db.models.CheckConstraint |
CheckConstraint.check | django.ref.models.constraints#django.db.models.CheckConstraint.check |
CheckConstraint.name | django.ref.models.constraints#django.db.models.CheckConstraint.name |
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 equiv... | django.ref.models.querysets#django.db.models.Count |
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. | django.ref.models.querysets#django.db.models.Count.distinct |
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 stor... | django.topics.db.sql#django.db.models.CursorWrapper.callproc |
class DateField(auto_now=False, auto_now_add=False, **options) | django.ref.models.fields#django.db.models.DateField |
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 m... | django.ref.models.fields#django.db.models.DateField.auto_now |
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 ... | django.ref.models.fields#django.db.models.DateField.auto_now_add |
class DateTimeField(auto_now=False, auto_now_add=False, **options) | django.ref.models.fields#django.db.models.DateTimeField |
class DecimalField(max_digits=None, decimal_places=None, **options) | django.ref.models.fields#django.db.models.DecimalField |
DecimalField.decimal_places
The number of decimal places to store with the number. | django.ref.models.fields#django.db.models.DecimalField.decimal_places |
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. | django.ref.models.fields#django.db.models.DecimalField.max_digits |
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. | django.ref.models.fields#django.db.models.DO_NOTHING |
class DurationField(**options) | django.ref.models.fields#django.db.models.DurationField |
class EmailField(max_length=254, **options) | django.ref.models.fields#django.db.models.EmailField |
class Exists(queryset) | django.ref.models.expressions#django.db.models.Exists |
class Expression
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 queri... | django.ref.models.expressions#django.db.models.Expression |
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. | django.ref.models.expressions#django.db.models.Expression.asc |
contains_aggregate
Tells Django that this expression contains an aggregate and that a GROUP BY clause needs to be added to the query. | django.ref.models.expressions#django.db.models.Expression.contains_aggregate |
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. | django.ref.models.expressions#django.db.models.Expression.contains_over_clause |
convert_value(value, expression, connection)
A hook allowing the expression to coerce value into a more appropriate type. expression is the same as self. | django.ref.models.expressions#django.db.models.Expression.convert_value |
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. | django.ref.models.expressions#django.db.models.Expression.desc |
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. | django.ref.models.expressions#django.db.models.Expression.empty_result_set_value |
filterable
Tells Django that this expression can be referenced in QuerySet.filter(). Defaults to True. | django.ref.models.expressions#django.db.models.Expression.filterable |
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... | django.ref.models.expressions#django.db.models.Expression.get_group_by_cols |
get_source_expressions()
Returns an ordered list of inner expressions. For example: >>> Sum(F('foo')).get_source_expressions()
[F('foo')] | django.ref.models.expressions#django.db.models.Expression.get_source_expressions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.