Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
ConfigOverrider.__apply_single_override | (self, dest, name, value) |
Apply single override
:type name: str
:type value: str
|
Apply single override
:type name: str
:type value: str
| def __apply_single_override(self, dest, name, value):
"""
Apply single override
:type name: str
:type value: str
"""
self.log.debug("Applying %s=%s", name, value)
parts = [(int(x) if is_int(x) else x) for x in name.split(".")]
pointer = dest
for in... | [
"def",
"__apply_single_override",
"(",
"self",
",",
"dest",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Applying %s=%s\"",
",",
"name",
",",
"value",
")",
"parts",
"=",
"[",
"(",
"int",
"(",
"x",
")",
"if",
"is_int"... | [
523,
4
] | [
578,
49
] | python | en | ['en', 'error', 'th'] | False |
ConfigOverrider.__ensure_list_capacity | (self, pointer, part, next_part=None) |
Extend pointer list to hold additional item
:type pointer: list
:type part: int
|
Extend pointer list to hold additional item
:type pointer: list
:type part: int
| def __ensure_list_capacity(self, pointer, part, next_part=None):
"""
Extend pointer list to hold additional item
:type pointer: list
:type part: int
"""
if isinstance(pointer, list) and isinstance(part, int):
while len(pointer) <= part:
self.lo... | [
"def",
"__ensure_list_capacity",
"(",
"self",
",",
"pointer",
",",
"part",
",",
"next_part",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"pointer",
",",
"list",
")",
"and",
"isinstance",
"(",
"part",
",",
"int",
")",
":",
"while",
"len",
"(",
"poin... | [
587,
4
] | [
599,
48
] | python | en | ['en', 'error', 'th'] | False |
MAP_inference.build_loss_and_gradients | (self, var_list) | Build loss function. Its automatic differentiation
is the gradient of
$- \log p(x,z).$
| Build loss function. Its automatic differentiation
is the gradient of | def build_loss_and_gradients(self, var_list):
"""Build loss function. Its automatic differentiation
is the gradient of
$- \log p(x,z).$
"""
# Form dictionary in order to replace conditioning on prior or
# observed variable with conditioning on a specific value.
scope = tf.get_default_graph(... | [
"def",
"build_loss_and_gradients",
"(",
"self",
",",
"var_list",
")",
":",
"# Form dictionary in order to replace conditioning on prior or",
"# observed variable with conditioning on a specific value.",
"scope",
"=",
"tf",
".",
"get_default_graph",
"(",
")",
".",
"unique_name",
... | [
12,
2
] | [
50,
31
] | python | en | ['en', 'en', 'en'] | True |
render_formset | (formset, **kwargs) | Render a formset to a Bootstrap layout. | Render a formset to a Bootstrap layout. | def render_formset(formset, **kwargs):
"""Render a formset to a Bootstrap layout."""
renderer_cls = get_formset_renderer(**kwargs)
return renderer_cls(formset, **kwargs).render() | [
"def",
"render_formset",
"(",
"formset",
",",
"*",
"*",
"kwargs",
")",
":",
"renderer_cls",
"=",
"get_formset_renderer",
"(",
"*",
"*",
"kwargs",
")",
"return",
"renderer_cls",
"(",
"formset",
",",
"*",
"*",
"kwargs",
")",
".",
"render",
"(",
")"
] | [
26,
0
] | [
29,
51
] | python | en | ['en', 'en', 'en'] | True |
render_formset_errors | (formset, **kwargs) | Render formset errors to a Bootstrap layout. | Render formset errors to a Bootstrap layout. | def render_formset_errors(formset, **kwargs):
"""Render formset errors to a Bootstrap layout."""
renderer_cls = get_formset_renderer(**kwargs)
return renderer_cls(formset, **kwargs).render_errors() | [
"def",
"render_formset_errors",
"(",
"formset",
",",
"*",
"*",
"kwargs",
")",
":",
"renderer_cls",
"=",
"get_formset_renderer",
"(",
"*",
"*",
"kwargs",
")",
"return",
"renderer_cls",
"(",
"formset",
",",
"*",
"*",
"kwargs",
")",
".",
"render_errors",
"(",
... | [
32,
0
] | [
35,
58
] | python | en | ['en', 'en', 'en'] | True |
render_form | (form, **kwargs) | Render a form to a Bootstrap layout. | Render a form to a Bootstrap layout. | def render_form(form, **kwargs):
"""Render a form to a Bootstrap layout."""
renderer_cls = get_form_renderer(**kwargs)
return renderer_cls(form, **kwargs).render() | [
"def",
"render_form",
"(",
"form",
",",
"*",
"*",
"kwargs",
")",
":",
"renderer_cls",
"=",
"get_form_renderer",
"(",
"*",
"*",
"kwargs",
")",
"return",
"renderer_cls",
"(",
"form",
",",
"*",
"*",
"kwargs",
")",
".",
"render",
"(",
")"
] | [
38,
0
] | [
41,
48
] | python | en | ['en', 'en', 'en'] | True |
render_form_errors | (form, error_types="non_field_errors", **kwargs) | Render form errors to a Bootstrap layout. | Render form errors to a Bootstrap layout. | def render_form_errors(form, error_types="non_field_errors", **kwargs):
"""Render form errors to a Bootstrap layout."""
renderer_cls = get_form_renderer(**kwargs)
return renderer_cls(form, **kwargs).render_errors(error_types) | [
"def",
"render_form_errors",
"(",
"form",
",",
"error_types",
"=",
"\"non_field_errors\"",
",",
"*",
"*",
"kwargs",
")",
":",
"renderer_cls",
"=",
"get_form_renderer",
"(",
"*",
"*",
"kwargs",
")",
"return",
"renderer_cls",
"(",
"form",
",",
"*",
"*",
"kwarg... | [
44,
0
] | [
47,
66
] | python | en | ['en', 'en', 'en'] | True |
render_field | (field, **kwargs) | Render a field to a Bootstrap layout. | Render a field to a Bootstrap layout. | def render_field(field, **kwargs):
"""Render a field to a Bootstrap layout."""
renderer_cls = get_field_renderer(**kwargs)
return renderer_cls(field, **kwargs).render() | [
"def",
"render_field",
"(",
"field",
",",
"*",
"*",
"kwargs",
")",
":",
"renderer_cls",
"=",
"get_field_renderer",
"(",
"*",
"*",
"kwargs",
")",
"return",
"renderer_cls",
"(",
"field",
",",
"*",
"*",
"kwargs",
")",
".",
"render",
"(",
")"
] | [
50,
0
] | [
53,
49
] | python | en | ['en', 'en', 'en'] | True |
render_label | (content, label_for=None, label_class=None, label_title="") | Render a label with content. | Render a label with content. | def render_label(content, label_for=None, label_class=None, label_title=""):
"""Render a label with content."""
attrs = {}
if label_for:
attrs["for"] = label_for
if label_class:
attrs["class"] = label_class
if label_title:
attrs["title"] = label_title
return render_tag("l... | [
"def",
"render_label",
"(",
"content",
",",
"label_for",
"=",
"None",
",",
"label_class",
"=",
"None",
",",
"label_title",
"=",
"\"\"",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"label_for",
":",
"attrs",
"[",
"\"for\"",
"]",
"=",
"label_for",
"if",
"lab... | [
56,
0
] | [
65,
60
] | python | en | ['en', 'en', 'en'] | True |
render_button | (
content,
button_type=None,
icon=None,
button_class="btn-default",
size="",
href="",
name=None,
value=None,
title=None,
extra_classes="",
id="",
) | Render a button with content. | Render a button with content. | def render_button(
content,
button_type=None,
icon=None,
button_class="btn-default",
size="",
href="",
name=None,
value=None,
title=None,
extra_classes="",
id="",
):
"""Render a button with content."""
attrs = {}
classes = add_css_class("btn", button_class)
si... | [
"def",
"render_button",
"(",
"content",
",",
"button_type",
"=",
"None",
",",
"icon",
"=",
"None",
",",
"button_class",
"=",
"\"btn-default\"",
",",
"size",
"=",
"\"\"",
",",
"href",
"=",
"\"\"",
",",
"name",
"=",
"None",
",",
"value",
"=",
"None",
","... | [
68,
0
] | [
119,
109
] | python | en | ['en', 'en', 'en'] | True |
render_field_and_label | (field, label, field_class="", label_for=None, label_class="", layout="", **kwargs) | Render a field with its label. | Render a field with its label. | def render_field_and_label(field, label, field_class="", label_for=None, label_class="", layout="", **kwargs):
"""Render a field with its label."""
if layout == "horizontal":
if not label_class:
label_class = get_bootstrap_setting("horizontal_label_class")
if not field_class:
... | [
"def",
"render_field_and_label",
"(",
"field",
",",
"label",
",",
"field_class",
"=",
"\"\"",
",",
"label_for",
"=",
"None",
",",
"label_class",
"=",
"\"\"",
",",
"layout",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"layout",
"==",
"\"horizont... | [
122,
0
] | [
137,
15
] | python | en | ['en', 'en', 'en'] | True |
render_form_group | (content, css_class=FORM_GROUP_CLASS) | Render a Bootstrap form group. | Render a Bootstrap form group. | def render_form_group(content, css_class=FORM_GROUP_CLASS):
"""Render a Bootstrap form group."""
return '<div class="{klass}">{content}</div>'.format(klass=css_class, content=content) | [
"def",
"render_form_group",
"(",
"content",
",",
"css_class",
"=",
"FORM_GROUP_CLASS",
")",
":",
"return",
"'<div class=\"{klass}\">{content}</div>'",
".",
"format",
"(",
"klass",
"=",
"css_class",
",",
"content",
"=",
"content",
")"
] | [
140,
0
] | [
142,
90
] | python | en | ['en', 'en', 'en'] | True |
is_widget_required_attribute | (widget) | Return whether this widget is required. | Return whether this widget is required. | def is_widget_required_attribute(widget):
"""Return whether this widget is required."""
if not widget.is_required:
return False
if isinstance(widget, WIDGETS_NO_REQUIRED):
return False
return True | [
"def",
"is_widget_required_attribute",
"(",
"widget",
")",
":",
"if",
"not",
"widget",
".",
"is_required",
":",
"return",
"False",
"if",
"isinstance",
"(",
"widget",
",",
"WIDGETS_NO_REQUIRED",
")",
":",
"return",
"False",
"return",
"True"
] | [
145,
0
] | [
151,
15
] | python | en | ['en', 'en', 'en'] | True |
is_widget_with_placeholder | (widget) |
Return whether this a widget that should have a placeholder.
Only text, search, url, tel, e-mail, password, number have placeholders
|
Return whether this a widget that should have a placeholder. | def is_widget_with_placeholder(widget):
"""
Return whether this a widget that should have a placeholder.
Only text, search, url, tel, e-mail, password, number have placeholders
"""
return isinstance(widget, (TextInput, Textarea, NumberInput, EmailInput, URLInput, PasswordInput)) | [
"def",
"is_widget_with_placeholder",
"(",
"widget",
")",
":",
"return",
"isinstance",
"(",
"widget",
",",
"(",
"TextInput",
",",
"Textarea",
",",
"NumberInput",
",",
"EmailInput",
",",
"URLInput",
",",
"PasswordInput",
")",
")"
] | [
154,
0
] | [
160,
102
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.autoinc_sql | (self, table, column) |
Returns any SQL needed to support auto-incrementing primary keys, or
None if no SQL is necessary.
This SQL is executed when a table is created.
|
Returns any SQL needed to support auto-incrementing primary keys, or
None if no SQL is necessary. | def autoinc_sql(self, table, column):
"""
Returns any SQL needed to support auto-incrementing primary keys, or
None if no SQL is necessary.
This SQL is executed when a table is created.
"""
return None | [
"def",
"autoinc_sql",
"(",
"self",
",",
"table",
",",
"column",
")",
":",
"return",
"None"
] | [
41,
4
] | [
48,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.bulk_batch_size | (self, fields, objs) |
Returns the maximum allowed batch size for the backend. The fields
are the fields going to be inserted in the batch, the objs contains
all the objects to be inserted.
|
Returns the maximum allowed batch size for the backend. The fields
are the fields going to be inserted in the batch, the objs contains
all the objects to be inserted.
| def bulk_batch_size(self, fields, objs):
"""
Returns the maximum allowed batch size for the backend. The fields
are the fields going to be inserted in the batch, the objs contains
all the objects to be inserted.
"""
return len(objs) | [
"def",
"bulk_batch_size",
"(",
"self",
",",
"fields",
",",
"objs",
")",
":",
"return",
"len",
"(",
"objs",
")"
] | [
50,
4
] | [
56,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.cache_key_culling_sql | (self) |
Returns an SQL query that retrieves the first cache key greater than the
n smallest.
This is used by the 'db' cache backend to determine where to start
culling.
|
Returns an SQL query that retrieves the first cache key greater than the
n smallest. | def cache_key_culling_sql(self):
"""
Returns an SQL query that retrieves the first cache key greater than the
n smallest.
This is used by the 'db' cache backend to determine where to start
culling.
"""
return "SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 O... | [
"def",
"cache_key_culling_sql",
"(",
"self",
")",
":",
"return",
"\"SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s\""
] | [
58,
4
] | [
66,
79
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.unification_cast_sql | (self, output_field) |
Given a field instance, returns the SQL necessary to cast the result of
a union to that type. Note that the resulting string should contain a
'%s' placeholder for the expression being cast.
|
Given a field instance, returns the SQL necessary to cast the result of
a union to that type. Note that the resulting string should contain a
'%s' placeholder for the expression being cast.
| def unification_cast_sql(self, output_field):
"""
Given a field instance, returns the SQL necessary to cast the result of
a union to that type. Note that the resulting string should contain a
'%s' placeholder for the expression being cast.
"""
return '%s' | [
"def",
"unification_cast_sql",
"(",
"self",
",",
"output_field",
")",
":",
"return",
"'%s'"
] | [
68,
4
] | [
74,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.date_extract_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
extracts a value from the given date field field_name.
|
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
extracts a value from the given date field field_name.
| def date_extract_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
extracts a value from the given date field field_name.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a date_extract_sql... | [
"def",
"date_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a date_extract_sql() method'",
")"
] | [
76,
4
] | [
81,
113
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.date_interval_sql | (self, timedelta) |
Implements the date interval functionality for expressions
|
Implements the date interval functionality for expressions
| def date_interval_sql(self, timedelta):
"""
Implements the date interval functionality for expressions
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a date_interval_sql() method') | [
"def",
"date_interval_sql",
"(",
"self",
",",
"timedelta",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a date_interval_sql() method'",
")"
] | [
83,
4
] | [
87,
114
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.date_trunc_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
truncates the given date field field_name to a date object with only
the given specificity.
|
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
truncates the given date field field_name to a date object with only
the given specificity.
| def date_trunc_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'year', 'month' or 'day', returns the SQL that
truncates the given date field field_name to a date object with only
the given specificity.
"""
raise NotImplementedError('subclasses of BaseDataba... | [
"def",
"date_trunc_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetrunc_sql() method'",
")"
] | [
89,
4
] | [
95,
110
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_cast_date_sql | (self, field_name, tzname) |
Returns the SQL necessary to cast a datetime value to date value.
|
Returns the SQL necessary to cast a datetime value to date value.
| def datetime_cast_date_sql(self, field_name, tzname):
"""
Returns the SQL necessary to cast a datetime value to date value.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a datetime_cast_date() method') | [
"def",
"datetime_cast_date_sql",
"(",
"self",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_cast_date() method'",
")"
] | [
97,
4
] | [
101,
115
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_cast_time_sql | (self, field_name, tzname) |
Returns the SQL necessary to cast a datetime value to time value.
|
Returns the SQL necessary to cast a datetime value to time value.
| def datetime_cast_time_sql(self, field_name, tzname):
"""
Returns the SQL necessary to cast a datetime value to time value.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a datetime_cast_time_sql() method') | [
"def",
"datetime_cast_time_sql",
"(",
"self",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_cast_time_sql() method'",
")"
] | [
103,
4
] | [
107,
119
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_extract_sql | (self, lookup_type, field_name, tzname) |
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or
'second', returns the SQL that extracts a value from the given
datetime field field_name, and a tuple of parameters.
|
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or
'second', returns the SQL that extracts a value from the given
datetime field field_name, and a tuple of parameters.
| def datetime_extract_sql(self, lookup_type, field_name, tzname):
"""
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or
'second', returns the SQL that extracts a value from the given
datetime field field_name, and a tuple of parameters.
"""
raise NotImplem... | [
"def",
"datetime_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_extract_sql() method'",
")"
] | [
109,
4
] | [
115,
117
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.datetime_trunc_sql | (self, lookup_type, field_name, tzname) |
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or
'second', returns the SQL that truncates the given datetime field
field_name to a datetime object with only the given specificity, and
a tuple of parameters.
|
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or
'second', returns the SQL that truncates the given datetime field
field_name to a datetime object with only the given specificity, and
a tuple of parameters.
| def datetime_trunc_sql(self, lookup_type, field_name, tzname):
"""
Given a lookup_type of 'year', 'month', 'day', 'hour', 'minute' or
'second', returns the SQL that truncates the given datetime field
field_name to a datetime object with only the given specificity, and
a tuple of ... | [
"def",
"datetime_trunc_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
",",
"tzname",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a datetime_trunk_sql() method'",
")"
] | [
117,
4
] | [
124,
115
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.time_trunc_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'hour', 'minute' or 'second', returns the SQL
that truncates the given time field field_name to a time object with
only the given specificity.
|
Given a lookup_type of 'hour', 'minute' or 'second', returns the SQL
that truncates the given time field field_name to a time object with
only the given specificity.
| def time_trunc_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'hour', 'minute' or 'second', returns the SQL
that truncates the given time field field_name to a time object with
only the given specificity.
"""
raise NotImplementedError('subclasses of BaseDa... | [
"def",
"time_trunc_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a time_trunc_sql() method'",
")"
] | [
126,
4
] | [
132,
111
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.time_extract_sql | (self, lookup_type, field_name) |
Given a lookup_type of 'hour', 'minute' or 'second', returns the SQL
that extracts a value from the given time field field_name.
|
Given a lookup_type of 'hour', 'minute' or 'second', returns the SQL
that extracts a value from the given time field field_name.
| def time_extract_sql(self, lookup_type, field_name):
"""
Given a lookup_type of 'hour', 'minute' or 'second', returns the SQL
that extracts a value from the given time field field_name.
"""
return self.date_extract_sql(lookup_type, field_name) | [
"def",
"time_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"return",
"self",
".",
"date_extract_sql",
"(",
"lookup_type",
",",
"field_name",
")"
] | [
134,
4
] | [
139,
61
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.deferrable_sql | (self) |
Returns the SQL necessary to make a constraint "initially deferred"
during a CREATE TABLE statement.
|
Returns the SQL necessary to make a constraint "initially deferred"
during a CREATE TABLE statement.
| def deferrable_sql(self):
"""
Returns the SQL necessary to make a constraint "initially deferred"
during a CREATE TABLE statement.
"""
return '' | [
"def",
"deferrable_sql",
"(",
"self",
")",
":",
"return",
"''"
] | [
141,
4
] | [
146,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.distinct_sql | (self, fields) |
Returns an SQL DISTINCT clause which removes duplicate rows from the
result set. If any fields are given, only the given fields are being
checked for duplicates.
|
Returns an SQL DISTINCT clause which removes duplicate rows from the
result set. If any fields are given, only the given fields are being
checked for duplicates.
| def distinct_sql(self, fields):
"""
Returns an SQL DISTINCT clause which removes duplicate rows from the
result set. If any fields are given, only the given fields are being
checked for duplicates.
"""
if fields:
raise NotImplementedError('DISTINCT ON fields i... | [
"def",
"distinct_sql",
"(",
"self",
",",
"fields",
")",
":",
"if",
"fields",
":",
"raise",
"NotImplementedError",
"(",
"'DISTINCT ON fields is not supported by this database backend'",
")",
"else",
":",
"return",
"'DISTINCT'"
] | [
148,
4
] | [
157,
29
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.fetch_returned_insert_id | (self, cursor) |
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table that has an auto-incrementing ID, returns the
newly created ID.
|
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table that has an auto-incrementing ID, returns the
newly created ID.
| def fetch_returned_insert_id(self, cursor):
"""
Given a cursor object that has just performed an INSERT...RETURNING
statement into a table that has an auto-incrementing ID, returns the
newly created ID.
"""
return cursor.fetchone()[0] | [
"def",
"fetch_returned_insert_id",
"(",
"self",
",",
"cursor",
")",
":",
"return",
"cursor",
".",
"fetchone",
"(",
")",
"[",
"0",
"]"
] | [
159,
4
] | [
165,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.field_cast_sql | (self, db_type, internal_type) |
Given a column type (e.g. 'BLOB', 'VARCHAR'), and an internal type
(e.g. 'GenericIPAddressField'), returns the SQL necessary to cast it
before using it in a WHERE statement. Note that the resulting string
should contain a '%s' placeholder for the column being searched against.
|
Given a column type (e.g. 'BLOB', 'VARCHAR'), and an internal type
(e.g. 'GenericIPAddressField'), returns the SQL necessary to cast it
before using it in a WHERE statement. Note that the resulting string
should contain a '%s' placeholder for the column being searched against.
| def field_cast_sql(self, db_type, internal_type):
"""
Given a column type (e.g. 'BLOB', 'VARCHAR'), and an internal type
(e.g. 'GenericIPAddressField'), returns the SQL necessary to cast it
before using it in a WHERE statement. Note that the resulting string
should contain a '%s'... | [
"def",
"field_cast_sql",
"(",
"self",
",",
"db_type",
",",
"internal_type",
")",
":",
"return",
"'%s'"
] | [
167,
4
] | [
174,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.force_no_ordering | (self) |
Returns a list used in the "ORDER BY" clause to force no ordering at
all. Returning an empty list means that nothing will be included in the
ordering.
|
Returns a list used in the "ORDER BY" clause to force no ordering at
all. Returning an empty list means that nothing will be included in the
ordering.
| def force_no_ordering(self):
"""
Returns a list used in the "ORDER BY" clause to force no ordering at
all. Returning an empty list means that nothing will be included in the
ordering.
"""
return [] | [
"def",
"force_no_ordering",
"(",
"self",
")",
":",
"return",
"[",
"]"
] | [
176,
4
] | [
182,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.for_update_sql | (self, nowait=False, skip_locked=False) |
Returns the FOR UPDATE SQL clause to lock rows for an update operation.
|
Returns the FOR UPDATE SQL clause to lock rows for an update operation.
| def for_update_sql(self, nowait=False, skip_locked=False):
"""
Returns the FOR UPDATE SQL clause to lock rows for an update operation.
"""
if nowait:
return 'FOR UPDATE NOWAIT'
elif skip_locked:
return 'FOR UPDATE SKIP LOCKED'
else:
ret... | [
"def",
"for_update_sql",
"(",
"self",
",",
"nowait",
"=",
"False",
",",
"skip_locked",
"=",
"False",
")",
":",
"if",
"nowait",
":",
"return",
"'FOR UPDATE NOWAIT'",
"elif",
"skip_locked",
":",
"return",
"'FOR UPDATE SKIP LOCKED'",
"else",
":",
"return",
"'FOR UP... | [
184,
4
] | [
193,
31
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.fulltext_search_sql | (self, field_name) |
Returns the SQL WHERE clause to use in order to perform a full-text
search of the given field_name. Note that the resulting string should
contain a '%s' placeholder for the value being searched against.
|
Returns the SQL WHERE clause to use in order to perform a full-text
search of the given field_name. Note that the resulting string should
contain a '%s' placeholder for the value being searched against.
| def fulltext_search_sql(self, field_name):
"""
Returns the SQL WHERE clause to use in order to perform a full-text
search of the given field_name. Note that the resulting string should
contain a '%s' placeholder for the value being searched against.
"""
# RemovedInDjango2... | [
"def",
"fulltext_search_sql",
"(",
"self",
",",
"field_name",
")",
":",
"# RemovedInDjango20Warning",
"raise",
"NotImplementedError",
"(",
"'Full-text search is not implemented for this database backend'",
")"
] | [
195,
4
] | [
202,
98
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.last_executed_query | (self, cursor, sql, params) |
Returns a string of the query last executed by the given cursor, with
placeholders replaced with actual values.
`sql` is the raw query containing placeholders, and `params` is the
sequence of parameters. These are used by default, but this method
exists for database backends to... |
Returns a string of the query last executed by the given cursor, with
placeholders replaced with actual values. | def last_executed_query(self, cursor, sql, params):
"""
Returns a string of the query last executed by the given cursor, with
placeholders replaced with actual values.
`sql` is the raw query containing placeholders, and `params` is the
sequence of parameters. These are used by d... | [
"def",
"last_executed_query",
"(",
"self",
",",
"cursor",
",",
"sql",
",",
"params",
")",
":",
"# Convert params to contain Unicode values.",
"def",
"to_unicode",
"(",
"s",
")",
":",
"return",
"force_text",
"(",
"s",
",",
"strings_only",
"=",
"True",
",",
"err... | [
204,
4
] | [
224,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.last_insert_id | (self, cursor, table_name, pk_name) |
Given a cursor object that has just performed an INSERT statement into
a table that has an auto-incrementing ID, returns the newly created ID.
This method also receives the table name and the name of the primary-key
column.
|
Given a cursor object that has just performed an INSERT statement into
a table that has an auto-incrementing ID, returns the newly created ID. | def last_insert_id(self, cursor, table_name, pk_name):
"""
Given a cursor object that has just performed an INSERT statement into
a table that has an auto-incrementing ID, returns the newly created ID.
This method also receives the table name and the name of the primary-key
colu... | [
"def",
"last_insert_id",
"(",
"self",
",",
"cursor",
",",
"table_name",
",",
"pk_name",
")",
":",
"return",
"cursor",
".",
"lastrowid"
] | [
226,
4
] | [
234,
31
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.lookup_cast | (self, lookup_type, internal_type=None) |
Returns the string to use in a query when performing lookups
("contains", "like", etc.). The resulting string should contain a '%s'
placeholder for the column being searched against.
|
Returns the string to use in a query when performing lookups
("contains", "like", etc.). The resulting string should contain a '%s'
placeholder for the column being searched against.
| def lookup_cast(self, lookup_type, internal_type=None):
"""
Returns the string to use in a query when performing lookups
("contains", "like", etc.). The resulting string should contain a '%s'
placeholder for the column being searched against.
"""
return "%s" | [
"def",
"lookup_cast",
"(",
"self",
",",
"lookup_type",
",",
"internal_type",
"=",
"None",
")",
":",
"return",
"\"%s\""
] | [
236,
4
] | [
242,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.max_in_list_size | (self) |
Returns the maximum number of items that can be passed in a single 'IN'
list condition, or None if the backend does not impose a limit.
|
Returns the maximum number of items that can be passed in a single 'IN'
list condition, or None if the backend does not impose a limit.
| def max_in_list_size(self):
"""
Returns the maximum number of items that can be passed in a single 'IN'
list condition, or None if the backend does not impose a limit.
"""
return None | [
"def",
"max_in_list_size",
"(",
"self",
")",
":",
"return",
"None"
] | [
244,
4
] | [
249,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.max_name_length | (self) |
Returns the maximum length of table and column names, or None if there
is no limit.
|
Returns the maximum length of table and column names, or None if there
is no limit.
| def max_name_length(self):
"""
Returns the maximum length of table and column names, or None if there
is no limit.
"""
return None | [
"def",
"max_name_length",
"(",
"self",
")",
":",
"return",
"None"
] | [
251,
4
] | [
256,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.no_limit_value | (self) |
Returns the value to use for the LIMIT when we are wanting "LIMIT
infinity". Returns None if the limit clause can be omitted in this case.
|
Returns the value to use for the LIMIT when we are wanting "LIMIT
infinity". Returns None if the limit clause can be omitted in this case.
| def no_limit_value(self):
"""
Returns the value to use for the LIMIT when we are wanting "LIMIT
infinity". Returns None if the limit clause can be omitted in this case.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a no_limit_value() method') | [
"def",
"no_limit_value",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a no_limit_value() method'",
")"
] | [
258,
4
] | [
263,
111
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.pk_default_value | (self) |
Returns the value to use during an INSERT statement to specify that
the field should use its default value.
|
Returns the value to use during an INSERT statement to specify that
the field should use its default value.
| def pk_default_value(self):
"""
Returns the value to use during an INSERT statement to specify that
the field should use its default value.
"""
return 'DEFAULT' | [
"def",
"pk_default_value",
"(",
"self",
")",
":",
"return",
"'DEFAULT'"
] | [
265,
4
] | [
270,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.prepare_sql_script | (self, sql) |
Takes an SQL script that may contain multiple lines and returns a list
of statements to feed to successive cursor.execute() calls.
Since few databases are able to process raw SQL scripts in a single
cursor.execute() call and PEP 249 doesn't talk about this use case,
the default... |
Takes an SQL script that may contain multiple lines and returns a list
of statements to feed to successive cursor.execute() calls. | def prepare_sql_script(self, sql):
"""
Takes an SQL script that may contain multiple lines and returns a list
of statements to feed to successive cursor.execute() calls.
Since few databases are able to process raw SQL scripts in a single
cursor.execute() call and PEP 249 doesn't... | [
"def",
"prepare_sql_script",
"(",
"self",
",",
"sql",
")",
":",
"try",
":",
"import",
"sqlparse",
"except",
"ImportError",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"sqlparse is required if you don't split your SQL \"",
"\"statements manually.\"",
")",
"else",
":",
"... | [
272,
4
] | [
290,
70
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.process_clob | (self, value) |
Returns the value of a CLOB column, for backends that return a locator
object that requires additional processing.
|
Returns the value of a CLOB column, for backends that return a locator
object that requires additional processing.
| def process_clob(self, value):
"""
Returns the value of a CLOB column, for backends that return a locator
object that requires additional processing.
"""
return value | [
"def",
"process_clob",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
292,
4
] | [
297,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.return_insert_id | (self) |
For backends that support returning the last insert ID as part
of an insert query, this method returns the SQL and params to
append to the INSERT query. The returned fragment should
contain a format string to hold the appropriate column.
|
For backends that support returning the last insert ID as part
of an insert query, this method returns the SQL and params to
append to the INSERT query. The returned fragment should
contain a format string to hold the appropriate column.
| def return_insert_id(self):
"""
For backends that support returning the last insert ID as part
of an insert query, this method returns the SQL and params to
append to the INSERT query. The returned fragment should
contain a format string to hold the appropriate column.
""... | [
"def",
"return_insert_id",
"(",
"self",
")",
":",
"pass"
] | [
299,
4
] | [
306,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.compiler | (self, compiler_name) |
Returns the SQLCompiler class corresponding to the given name,
in the namespace corresponding to the `compiler_module` attribute
on this backend.
|
Returns the SQLCompiler class corresponding to the given name,
in the namespace corresponding to the `compiler_module` attribute
on this backend.
| def compiler(self, compiler_name):
"""
Returns the SQLCompiler class corresponding to the given name,
in the namespace corresponding to the `compiler_module` attribute
on this backend.
"""
if self._cache is None:
self._cache = import_module(self.compiler_modul... | [
"def",
"compiler",
"(",
"self",
",",
"compiler_name",
")",
":",
"if",
"self",
".",
"_cache",
"is",
"None",
":",
"self",
".",
"_cache",
"=",
"import_module",
"(",
"self",
".",
"compiler_module",
")",
"return",
"getattr",
"(",
"self",
".",
"_cache",
",",
... | [
308,
4
] | [
316,
50
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.quote_name | (self, name) |
Returns a quoted version of the given table, index or column name. Does
not quote the given name if it's already been quoted.
|
Returns a quoted version of the given table, index or column name. Does
not quote the given name if it's already been quoted.
| def quote_name(self, name):
"""
Returns a quoted version of the given table, index or column name. Does
not quote the given name if it's already been quoted.
"""
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a quote_name() method') | [
"def",
"quote_name",
"(",
"self",
",",
"name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a quote_name() method'",
")"
] | [
318,
4
] | [
323,
107
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.random_function_sql | (self) |
Returns an SQL expression that returns a random value.
|
Returns an SQL expression that returns a random value.
| def random_function_sql(self):
"""
Returns an SQL expression that returns a random value.
"""
return 'RANDOM()' | [
"def",
"random_function_sql",
"(",
"self",
")",
":",
"return",
"'RANDOM()'"
] | [
325,
4
] | [
329,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.regex_lookup | (self, lookup_type) |
Returns the string to use in a query when performing regular expression
lookups (using "regex" or "iregex"). The resulting string should
contain a '%s' placeholder for the column being searched against.
If the feature is not supported (or part of it is not supported), a
NotImpl... |
Returns the string to use in a query when performing regular expression
lookups (using "regex" or "iregex"). The resulting string should
contain a '%s' placeholder for the column being searched against. | def regex_lookup(self, lookup_type):
"""
Returns the string to use in a query when performing regular expression
lookups (using "regex" or "iregex"). The resulting string should
contain a '%s' placeholder for the column being searched against.
If the feature is not supported (or... | [
"def",
"regex_lookup",
"(",
"self",
",",
"lookup_type",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations may require a regex_lookup() method'",
")"
] | [
331,
4
] | [
340,
109
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.savepoint_create_sql | (self, sid) |
Returns the SQL for starting a new savepoint. Only required if the
"uses_savepoints" feature is True. The "sid" parameter is a string
for the savepoint id.
|
Returns the SQL for starting a new savepoint. Only required if the
"uses_savepoints" feature is True. The "sid" parameter is a string
for the savepoint id.
| def savepoint_create_sql(self, sid):
"""
Returns the SQL for starting a new savepoint. Only required if the
"uses_savepoints" feature is True. The "sid" parameter is a string
for the savepoint id.
"""
return "SAVEPOINT %s" % self.quote_name(sid) | [
"def",
"savepoint_create_sql",
"(",
"self",
",",
"sid",
")",
":",
"return",
"\"SAVEPOINT %s\"",
"%",
"self",
".",
"quote_name",
"(",
"sid",
")"
] | [
342,
4
] | [
348,
52
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.savepoint_commit_sql | (self, sid) |
Returns the SQL for committing the given savepoint.
|
Returns the SQL for committing the given savepoint.
| def savepoint_commit_sql(self, sid):
"""
Returns the SQL for committing the given savepoint.
"""
return "RELEASE SAVEPOINT %s" % self.quote_name(sid) | [
"def",
"savepoint_commit_sql",
"(",
"self",
",",
"sid",
")",
":",
"return",
"\"RELEASE SAVEPOINT %s\"",
"%",
"self",
".",
"quote_name",
"(",
"sid",
")"
] | [
350,
4
] | [
354,
60
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.savepoint_rollback_sql | (self, sid) |
Returns the SQL for rolling back the given savepoint.
|
Returns the SQL for rolling back the given savepoint.
| def savepoint_rollback_sql(self, sid):
"""
Returns the SQL for rolling back the given savepoint.
"""
return "ROLLBACK TO SAVEPOINT %s" % self.quote_name(sid) | [
"def",
"savepoint_rollback_sql",
"(",
"self",
",",
"sid",
")",
":",
"return",
"\"ROLLBACK TO SAVEPOINT %s\"",
"%",
"self",
".",
"quote_name",
"(",
"sid",
")"
] | [
356,
4
] | [
360,
64
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.set_time_zone_sql | (self) |
Returns the SQL that will set the connection's time zone.
Returns '' if the backend doesn't support time zones.
|
Returns the SQL that will set the connection's time zone. | def set_time_zone_sql(self):
"""
Returns the SQL that will set the connection's time zone.
Returns '' if the backend doesn't support time zones.
"""
return '' | [
"def",
"set_time_zone_sql",
"(",
"self",
")",
":",
"return",
"''"
] | [
362,
4
] | [
368,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.sql_flush | (self, style, tables, sequences, allow_cascade=False) |
Returns a list of SQL statements required to remove all data from
the given database tables (without actually removing the tables
themselves).
The returned value also includes SQL statements required to reset DB
sequences passed in :param sequences:.
The `style` argume... |
Returns a list of SQL statements required to remove all data from
the given database tables (without actually removing the tables
themselves). | def sql_flush(self, style, tables, sequences, allow_cascade=False):
"""
Returns a list of SQL statements required to remove all data from
the given database tables (without actually removing the tables
themselves).
The returned value also includes SQL statements required to rese... | [
"def",
"sql_flush",
"(",
"self",
",",
"style",
",",
"tables",
",",
"sequences",
",",
"allow_cascade",
"=",
"False",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseOperations must provide an sql_flush() method'",
")"
] | [
370,
4
] | [
386,
108
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.sequence_reset_by_name_sql | (self, style, sequences) |
Returns a list of the SQL statements required to reset sequences
passed in :param sequences:.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
|
Returns a list of the SQL statements required to reset sequences
passed in :param sequences:. | def sequence_reset_by_name_sql(self, style, sequences):
"""
Returns a list of the SQL statements required to reset sequences
passed in :param sequences:.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
... | [
"def",
"sequence_reset_by_name_sql",
"(",
"self",
",",
"style",
",",
"sequences",
")",
":",
"return",
"[",
"]"
] | [
388,
4
] | [
396,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.sequence_reset_sql | (self, style, model_list) |
Returns a list of the SQL statements required to reset sequences for
the given models.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
|
Returns a list of the SQL statements required to reset sequences for
the given models. | def sequence_reset_sql(self, style, model_list):
"""
Returns a list of the SQL statements required to reset sequences for
the given models.
The `style` argument is a Style object as returned by either
color_style() or no_style() in django.core.management.color.
"""
... | [
"def",
"sequence_reset_sql",
"(",
"self",
",",
"style",
",",
"model_list",
")",
":",
"return",
"[",
"]"
] | [
398,
4
] | [
406,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.start_transaction_sql | (self) |
Returns the SQL statement required to start a transaction.
|
Returns the SQL statement required to start a transaction.
| def start_transaction_sql(self):
"""
Returns the SQL statement required to start a transaction.
"""
return "BEGIN;" | [
"def",
"start_transaction_sql",
"(",
"self",
")",
":",
"return",
"\"BEGIN;\""
] | [
408,
4
] | [
412,
23
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.end_transaction_sql | (self, success=True) |
Returns the SQL statement required to end a transaction.
|
Returns the SQL statement required to end a transaction.
| def end_transaction_sql(self, success=True):
"""
Returns the SQL statement required to end a transaction.
"""
if not success:
return "ROLLBACK;"
return "COMMIT;" | [
"def",
"end_transaction_sql",
"(",
"self",
",",
"success",
"=",
"True",
")",
":",
"if",
"not",
"success",
":",
"return",
"\"ROLLBACK;\"",
"return",
"\"COMMIT;\""
] | [
414,
4
] | [
420,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.tablespace_sql | (self, tablespace, inline=False) |
Returns the SQL that will be used in a query to define the tablespace.
Returns '' if the backend doesn't support tablespaces.
If inline is True, the SQL is appended to a row; otherwise it's appended
to the entire CREATE TABLE or CREATE INDEX statement.
|
Returns the SQL that will be used in a query to define the tablespace. | def tablespace_sql(self, tablespace, inline=False):
"""
Returns the SQL that will be used in a query to define the tablespace.
Returns '' if the backend doesn't support tablespaces.
If inline is True, the SQL is appended to a row; otherwise it's appended
to the entire CREATE TA... | [
"def",
"tablespace_sql",
"(",
"self",
",",
"tablespace",
",",
"inline",
"=",
"False",
")",
":",
"return",
"''"
] | [
422,
4
] | [
431,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.prep_for_like_query | (self, x) | Prepares a value for use in a LIKE query. | Prepares a value for use in a LIKE query. | def prep_for_like_query(self, x):
"""Prepares a value for use in a LIKE query."""
return force_text(x).replace("\\", "\\\\").replace("%", r"\%").replace("_", r"\_") | [
"def",
"prep_for_like_query",
"(",
"self",
",",
"x",
")",
":",
"return",
"force_text",
"(",
"x",
")",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"\\\\\\\\\"",
")",
".",
"replace",
"(",
"\"%\"",
",",
"r\"\\%\"",
")",
".",
"replace",
"(",
"\"_\"",
",",
"r\"... | [
433,
4
] | [
435,
90
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.validate_autopk_value | (self, value) |
Certain backends do not accept some values for "serial" fields
(for example zero in MySQL). This method will raise a ValueError
if the value is invalid, otherwise returns validated value.
|
Certain backends do not accept some values for "serial" fields
(for example zero in MySQL). This method will raise a ValueError
if the value is invalid, otherwise returns validated value.
| def validate_autopk_value(self, value):
"""
Certain backends do not accept some values for "serial" fields
(for example zero in MySQL). This method will raise a ValueError
if the value is invalid, otherwise returns validated value.
"""
return value | [
"def",
"validate_autopk_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
441,
4
] | [
447,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_unknown_value | (self, value) |
Transforms a value to something compatible with the backend driver.
This method only depends on the type of the value. It's designed for
cases where the target type isn't known, such as .raw() SQL queries.
As a consequence it may not work perfectly in all circumstances.
|
Transforms a value to something compatible with the backend driver. | def adapt_unknown_value(self, value):
"""
Transforms a value to something compatible with the backend driver.
This method only depends on the type of the value. It's designed for
cases where the target type isn't known, such as .raw() SQL queries.
As a consequence it may not wor... | [
"def",
"adapt_unknown_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"# must be before date",
"return",
"self",
".",
"adapt_datetimefield_value",
"(",
"value",
")",
"elif",
"isinstance",... | [
449,
4
] | [
466,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_datefield_value | (self, value) |
Transforms a date value to an object compatible with what is expected
by the backend driver for date columns.
|
Transforms a date value to an object compatible with what is expected
by the backend driver for date columns.
| def adapt_datefield_value(self, value):
"""
Transforms a date value to an object compatible with what is expected
by the backend driver for date columns.
"""
if value is None:
return None
return six.text_type(value) | [
"def",
"adapt_datefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"six",
".",
"text_type",
"(",
"value",
")"
] | [
468,
4
] | [
475,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_datetimefield_value | (self, value) |
Transforms a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
|
Transforms a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
| def adapt_datetimefield_value(self, value):
"""
Transforms a datetime value to an object compatible with what is expected
by the backend driver for datetime columns.
"""
if value is None:
return None
return six.text_type(value) | [
"def",
"adapt_datetimefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"return",
"six",
".",
"text_type",
"(",
"value",
")"
] | [
477,
4
] | [
484,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_timefield_value | (self, value) |
Transforms a time value to an object compatible with what is expected
by the backend driver for time columns.
|
Transforms a time value to an object compatible with what is expected
by the backend driver for time columns.
| def adapt_timefield_value(self, value):
"""
Transforms a time value to an object compatible with what is expected
by the backend driver for time columns.
"""
if value is None:
return None
if timezone.is_aware(value):
raise ValueError("Django does n... | [
"def",
"adapt_timefield_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"timezone",
".",
"is_aware",
"(",
"value",
")",
":",
"raise",
"ValueError",
"(",
"\"Django does not support timezone-aware times.\"",
"... | [
486,
4
] | [
495,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_decimalfield_value | (self, value, max_digits=None, decimal_places=None) |
Transforms a decimal.Decimal value to an object compatible with what is
expected by the backend driver for decimal (numeric) columns.
|
Transforms a decimal.Decimal value to an object compatible with what is
expected by the backend driver for decimal (numeric) columns.
| def adapt_decimalfield_value(self, value, max_digits=None, decimal_places=None):
"""
Transforms a decimal.Decimal value to an object compatible with what is
expected by the backend driver for decimal (numeric) columns.
"""
return utils.format_number(value, max_digits, decimal_pla... | [
"def",
"adapt_decimalfield_value",
"(",
"self",
",",
"value",
",",
"max_digits",
"=",
"None",
",",
"decimal_places",
"=",
"None",
")",
":",
"return",
"utils",
".",
"format_number",
"(",
"value",
",",
"max_digits",
",",
"decimal_places",
")"
] | [
497,
4
] | [
502,
69
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.adapt_ipaddressfield_value | (self, value) |
Transforms a string representation of an IP address into the expected
type for the backend driver.
|
Transforms a string representation of an IP address into the expected
type for the backend driver.
| def adapt_ipaddressfield_value(self, value):
"""
Transforms a string representation of an IP address into the expected
type for the backend driver.
"""
return value or None | [
"def",
"adapt_ipaddressfield_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"value",
"or",
"None"
] | [
504,
4
] | [
509,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.year_lookup_bounds_for_date_field | (self, value) |
Returns a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateField value using a year
lookup.
`value` is an int, containing the looked-up year.
|
Returns a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateField value using a year
lookup. | def year_lookup_bounds_for_date_field(self, value):
"""
Returns a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateField value using a year
lookup.
`value` is an int, containing the looked-up year.
"""
first = dat... | [
"def",
"year_lookup_bounds_for_date_field",
"(",
"self",
",",
"value",
")",
":",
"first",
"=",
"datetime",
".",
"date",
"(",
"value",
",",
"1",
",",
"1",
")",
"second",
"=",
"datetime",
".",
"date",
"(",
"value",
",",
"12",
",",
"31",
")",
"first",
"... | [
511,
4
] | [
523,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.year_lookup_bounds_for_datetime_field | (self, value) |
Returns a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateTimeField value using a year
lookup.
`value` is an int, containing the looked-up year.
|
Returns a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateTimeField value using a year
lookup. | def year_lookup_bounds_for_datetime_field(self, value):
"""
Returns a two-elements list with the lower and upper bound to be used
with a BETWEEN operator to query a DateTimeField value using a year
lookup.
`value` is an int, containing the looked-up year.
"""
fir... | [
"def",
"year_lookup_bounds_for_datetime_field",
"(",
"self",
",",
"value",
")",
":",
"first",
"=",
"datetime",
".",
"datetime",
"(",
"value",
",",
"1",
",",
"1",
")",
"second",
"=",
"datetime",
".",
"datetime",
"(",
"value",
",",
"12",
",",
"31",
",",
... | [
525,
4
] | [
541,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.get_db_converters | (self, expression) |
Get a list of functions needed to convert field data.
Some field types on some backends do not provide data in the correct
format, this is the hook for converter functions.
|
Get a list of functions needed to convert field data. | def get_db_converters(self, expression):
"""
Get a list of functions needed to convert field data.
Some field types on some backends do not provide data in the correct
format, this is the hook for converter functions.
"""
return [] | [
"def",
"get_db_converters",
"(",
"self",
",",
"expression",
")",
":",
"return",
"[",
"]"
] | [
543,
4
] | [
550,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.check_expression_support | (self, expression) |
Check that the backend supports the provided expression.
This is used on specific backends to rule out known expressions
that have problematic or nonexistent implementations. If the
expression has a known problem, the backend should raise
NotImplementedError.
|
Check that the backend supports the provided expression. | def check_expression_support(self, expression):
"""
Check that the backend supports the provided expression.
This is used on specific backends to rule out known expressions
that have problematic or nonexistent implementations. If the
expression has a known problem, the backend s... | [
"def",
"check_expression_support",
"(",
"self",
",",
"expression",
")",
":",
"pass"
] | [
565,
4
] | [
574,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.combine_expression | (self, connector, sub_expressions) | Combine a list of subexpressions into a single expression, using
the provided connecting operator. This is required because operators
can vary between backends (e.g., Oracle with %% and &) and between
subexpression types (e.g., date expressions)
| Combine a list of subexpressions into a single expression, using
the provided connecting operator. This is required because operators
can vary between backends (e.g., Oracle with %% and &) and between
subexpression types (e.g., date expressions)
| def combine_expression(self, connector, sub_expressions):
"""Combine a list of subexpressions into a single expression, using
the provided connecting operator. This is required because operators
can vary between backends (e.g., Oracle with %% and &) and between
subexpression types (e.g.,... | [
"def",
"combine_expression",
"(",
"self",
",",
"connector",
",",
"sub_expressions",
")",
":",
"conn",
"=",
"' %s '",
"%",
"connector",
"return",
"conn",
".",
"join",
"(",
"sub_expressions",
")"
] | [
576,
4
] | [
583,
41
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.binary_placeholder_sql | (self, value) |
Some backends require special syntax to insert binary content (MySQL
for example uses '_binary %s').
|
Some backends require special syntax to insert binary content (MySQL
for example uses '_binary %s').
| def binary_placeholder_sql(self, value):
"""
Some backends require special syntax to insert binary content (MySQL
for example uses '_binary %s').
"""
return '%s' | [
"def",
"binary_placeholder_sql",
"(",
"self",
",",
"value",
")",
":",
"return",
"'%s'"
] | [
588,
4
] | [
593,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseOperations.modify_insert_params | (self, placeholder, params) | Allow modification of insert parameters. Needed for Oracle Spatial
backend due to #10888.
| Allow modification of insert parameters. Needed for Oracle Spatial
backend due to #10888.
| def modify_insert_params(self, placeholder, params):
"""Allow modification of insert parameters. Needed for Oracle Spatial
backend due to #10888.
"""
return params | [
"def",
"modify_insert_params",
"(",
"self",
",",
"placeholder",
",",
"params",
")",
":",
"return",
"params"
] | [
595,
4
] | [
599,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseDatabaseOperations.integer_field_range | (self, internal_type) |
Given an integer field internal type (e.g. 'PositiveIntegerField'),
returns a tuple of the (min_value, max_value) form representing the
range of the column type bound to the field.
|
Given an integer field internal type (e.g. 'PositiveIntegerField'),
returns a tuple of the (min_value, max_value) form representing the
range of the column type bound to the field.
| def integer_field_range(self, internal_type):
"""
Given an integer field internal type (e.g. 'PositiveIntegerField'),
returns a tuple of the (min_value, max_value) form representing the
range of the column type bound to the field.
"""
return self.integer_field_ranges[inte... | [
"def",
"integer_field_range",
"(",
"self",
",",
"internal_type",
")",
":",
"return",
"self",
".",
"integer_field_ranges",
"[",
"internal_type",
"]"
] | [
601,
4
] | [
607,
55
] | python | en | ['en', 'error', 'th'] | False |
check_dependencies | (**kwargs) |
Check that the admin's dependencies are correctly installed.
|
Check that the admin's dependencies are correctly installed.
| def check_dependencies(**kwargs):
"""
Check that the admin's dependencies are correctly installed.
"""
errors = []
# contrib.contenttypes must be installed.
if not apps.is_installed('django.contrib.contenttypes'):
missing_app = checks.Error(
"'django.contrib.contenttypes' mus... | [
"def",
"check_dependencies",
"(",
"*",
"*",
"kwargs",
")",
":",
"errors",
"=",
"[",
"]",
"# contrib.contenttypes must be installed.",
"if",
"not",
"apps",
".",
"is_installed",
"(",
"'django.contrib.contenttypes'",
")",
":",
"missing_app",
"=",
"checks",
".",
"Erro... | [
28,
0
] | [
64,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdminChecks._check_raw_id_fields | (self, obj) | Check that `raw_id_fields` only contains field names that are listed
on the model. | Check that `raw_id_fields` only contains field names that are listed
on the model. | def _check_raw_id_fields(self, obj):
""" Check that `raw_id_fields` only contains field names that are listed
on the model. """
if not isinstance(obj.raw_id_fields, (list, tuple)):
return must_be('a list or tuple', option='raw_id_fields', obj=obj, id='admin.E001')
else:
... | [
"def",
"_check_raw_id_fields",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
".",
"raw_id_fields",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",
"'raw_id_fields... | [
85,
4
] | [
95,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_raw_id_fields_item | (self, obj, model, field_name, label) | Check an item of `raw_id_fields`, i.e. check that field named
`field_name` exists in model `model` and is a ForeignKey or a
ManyToManyField. | Check an item of `raw_id_fields`, i.e. check that field named
`field_name` exists in model `model` and is a ForeignKey or a
ManyToManyField. | def _check_raw_id_fields_item(self, obj, model, field_name, label):
""" Check an item of `raw_id_fields`, i.e. check that field named
`field_name` exists in model `model` and is a ForeignKey or a
ManyToManyField. """
try:
field = model._meta.get_field(field_name)
exc... | [
"def",
"_check_raw_id_fields_item",
"(",
"self",
",",
"obj",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"return",
"... | [
97,
4
] | [
112,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_fields | (self, obj) | Check that `fields` only refer to existing fields, doesn't contain
duplicates. Check if at most one of `fields` and `fieldsets` is defined.
| Check that `fields` only refer to existing fields, doesn't contain
duplicates. Check if at most one of `fields` and `fieldsets` is defined.
| def _check_fields(self, obj):
""" Check that `fields` only refer to existing fields, doesn't contain
duplicates. Check if at most one of `fields` and `fieldsets` is defined.
"""
if obj.fields is None:
return []
elif not isinstance(obj.fields, (list, tuple)):
... | [
"def",
"_check_fields",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"fields",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"fields",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be"... | [
114,
4
] | [
144,
11
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_fieldsets | (self, obj) | Check that fieldsets is properly formatted and doesn't contain
duplicates. | Check that fieldsets is properly formatted and doesn't contain
duplicates. | def _check_fieldsets(self, obj):
""" Check that fieldsets is properly formatted and doesn't contain
duplicates. """
if obj.fieldsets is None:
return []
elif not isinstance(obj.fieldsets, (list, tuple)):
return must_be('a list or tuple', option='fieldsets', obj=ob... | [
"def",
"_check_fieldsets",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"fieldsets",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"fieldsets",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
... | [
146,
4
] | [
158,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_fieldsets_item | (self, obj, model, fieldset, label) | Check an item of `fieldsets`, i.e. check that this is a pair of a
set name and a dictionary containing "fields" key. | Check an item of `fieldsets`, i.e. check that this is a pair of a
set name and a dictionary containing "fields" key. | def _check_fieldsets_item(self, obj, model, fieldset, label):
""" Check an item of `fieldsets`, i.e. check that this is a pair of a
set name and a dictionary containing "fields" key. """
if not isinstance(fieldset, (list, tuple)):
return must_be('a list or tuple', option=label, obj=... | [
"def",
"_check_fieldsets_item",
"(",
"self",
",",
"obj",
",",
"model",
",",
"fieldset",
",",
"label",
")",
":",
"if",
"not",
"isinstance",
"(",
"fieldset",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",... | [
160,
4
] | [
193,
11
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_field_spec | (self, obj, model, fields, label) | `fields` should be an item of `fields` or an item of
fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
field name or a tuple of field names. | `fields` should be an item of `fields` or an item of
fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
field name or a tuple of field names. | def _check_field_spec(self, obj, model, fields, label):
""" `fields` should be an item of `fields` or an item of
fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
field name or a tuple of field names. """
if isinstance(fields, tuple):
return list(chain(... | [
"def",
"_check_field_spec",
"(",
"self",
",",
"obj",
",",
"model",
",",
"fields",
",",
"label",
")",
":",
"if",
"isinstance",
"(",
"fields",
",",
"tuple",
")",
":",
"return",
"list",
"(",
"chain",
"(",
"*",
"[",
"self",
".",
"_check_field_spec_item",
"... | [
195,
4
] | [
206,
73
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_exclude | (self, obj) | Check that exclude is a sequence without duplicates. | Check that exclude is a sequence without duplicates. | def _check_exclude(self, obj):
""" Check that exclude is a sequence without duplicates. """
if obj.exclude is None: # default value is None
return []
elif not isinstance(obj.exclude, (list, tuple)):
return must_be('a list or tuple', option='exclude', obj=obj, id='admin.... | [
"def",
"_check_exclude",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"exclude",
"is",
"None",
":",
"# default value is None",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"exclude",
",",
"(",
"list",
",",
"tuple",
")",
")"... | [
236,
4
] | [
252,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_form | (self, obj) | Check that form subclasses BaseModelForm. | Check that form subclasses BaseModelForm. | def _check_form(self, obj):
""" Check that form subclasses BaseModelForm. """
if hasattr(obj, 'form') and not issubclass(obj.form, BaseModelForm):
return must_inherit_from(parent='BaseModelForm', option='form',
obj=obj, id='admin.E016')
else:
... | [
"def",
"_check_form",
"(",
"self",
",",
"obj",
")",
":",
"if",
"hasattr",
"(",
"obj",
",",
"'form'",
")",
"and",
"not",
"issubclass",
"(",
"obj",
".",
"form",
",",
"BaseModelForm",
")",
":",
"return",
"must_inherit_from",
"(",
"parent",
"=",
"'BaseModelF... | [
254,
4
] | [
261,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_filter_vertical | (self, obj) | Check that filter_vertical is a sequence of field names. | Check that filter_vertical is a sequence of field names. | def _check_filter_vertical(self, obj):
""" Check that filter_vertical is a sequence of field names. """
if not hasattr(obj, 'filter_vertical'):
return []
elif not isinstance(obj.filter_vertical, (list, tuple)):
return must_be('a list or tuple', option='filter_vertical', ... | [
"def",
"_check_filter_vertical",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'filter_vertical'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"filter_vertical",
",",
"(",
"list",
",",
"tuple... | [
263,
4
] | [
274,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_filter_horizontal | (self, obj) | Check that filter_horizontal is a sequence of field names. | Check that filter_horizontal is a sequence of field names. | def _check_filter_horizontal(self, obj):
""" Check that filter_horizontal is a sequence of field names. """
if not hasattr(obj, 'filter_horizontal'):
return []
elif not isinstance(obj.filter_horizontal, (list, tuple)):
return must_be('a list or tuple', option='filter_hor... | [
"def",
"_check_filter_horizontal",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'filter_horizontal'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"filter_horizontal",
",",
"(",
"list",
",",
... | [
276,
4
] | [
287,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_filter_item | (self, obj, model, field_name, label) | Check one item of `filter_vertical` or `filter_horizontal`, i.e.
check that given field exists and is a ManyToManyField. | Check one item of `filter_vertical` or `filter_horizontal`, i.e.
check that given field exists and is a ManyToManyField. | def _check_filter_item(self, obj, model, field_name, label):
""" Check one item of `filter_vertical` or `filter_horizontal`, i.e.
check that given field exists and is a ManyToManyField. """
try:
field = model._meta.get_field(field_name)
except FieldDoesNotExist:
... | [
"def",
"_check_filter_item",
"(",
"self",
",",
"obj",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"return",
"refer_t... | [
289,
4
] | [
302,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_radio_fields | (self, obj) | Check that `radio_fields` is a dictionary. | Check that `radio_fields` is a dictionary. | def _check_radio_fields(self, obj):
""" Check that `radio_fields` is a dictionary. """
if not hasattr(obj, 'radio_fields'):
return []
elif not isinstance(obj.radio_fields, dict):
return must_be('a dictionary', option='radio_fields', obj=obj, id='admin.E021')
else... | [
"def",
"_check_radio_fields",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'radio_fields'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"radio_fields",
",",
"dict",
")",
":",
"return",
"mu... | [
304,
4
] | [
316,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_radio_fields_key | (self, obj, model, field_name, label) | Check that a key of `radio_fields` dictionary is name of existing
field and that the field is a ForeignKey or has `choices` defined. | Check that a key of `radio_fields` dictionary is name of existing
field and that the field is a ForeignKey or has `choices` defined. | def _check_radio_fields_key(self, obj, model, field_name, label):
""" Check that a key of `radio_fields` dictionary is name of existing
field and that the field is a ForeignKey or has `choices` defined. """
try:
field = model._meta.get_field(field_name)
except FieldDoesNotEx... | [
"def",
"_check_radio_fields_key",
"(",
"self",
",",
"obj",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"return",
"re... | [
318,
4
] | [
340,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_radio_fields_value | (self, obj, val, label) | Check type of a value of `radio_fields` dictionary. | Check type of a value of `radio_fields` dictionary. | def _check_radio_fields_value(self, obj, val, label):
""" Check type of a value of `radio_fields` dictionary. """
from django.contrib.admin.options import HORIZONTAL, VERTICAL
if val not in (HORIZONTAL, VERTICAL):
return [
checks.Error(
"The valu... | [
"def",
"_check_radio_fields_value",
"(",
"self",
",",
"obj",
",",
"val",
",",
"label",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"options",
"import",
"HORIZONTAL",
",",
"VERTICAL",
"if",
"val",
"not",
"in",
"(",
"HORIZONTAL",
",",
"V... | [
342,
4
] | [
356,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields | (self, obj) | Check that `prepopulated_fields` is a dictionary containing allowed
field types. | Check that `prepopulated_fields` is a dictionary containing allowed
field types. | def _check_prepopulated_fields(self, obj):
""" Check that `prepopulated_fields` is a dictionary containing allowed
field types. """
if not hasattr(obj, 'prepopulated_fields'):
return []
elif not isinstance(obj.prepopulated_fields, dict):
return must_be('a diction... | [
"def",
"_check_prepopulated_fields",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'prepopulated_fields'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"prepopulated_fields",
",",
"dict",
")",
"... | [
373,
4
] | [
386,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields_key | (self, obj, model, field_name, label) | Check a key of `prepopulated_fields` dictionary, i.e. check that it
is a name of existing field and the field is one of the allowed types.
| Check a key of `prepopulated_fields` dictionary, i.e. check that it
is a name of existing field and the field is one of the allowed types.
| def _check_prepopulated_fields_key(self, obj, model, field_name, label):
""" Check a key of `prepopulated_fields` dictionary, i.e. check that it
is a name of existing field and the field is one of the allowed types.
"""
try:
field = model._meta.get_field(field_name)
... | [
"def",
"_check_prepopulated_fields_key",
"(",
"self",
",",
"obj",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"return"... | [
388,
4
] | [
409,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields_value | (self, obj, model, val, label) | Check a value of `prepopulated_fields` dictionary, i.e. it's an
iterable of existing fields. | Check a value of `prepopulated_fields` dictionary, i.e. it's an
iterable of existing fields. | def _check_prepopulated_fields_value(self, obj, model, val, label):
""" Check a value of `prepopulated_fields` dictionary, i.e. it's an
iterable of existing fields. """
if not isinstance(val, (list, tuple)):
return must_be('a list or tuple', option=label, obj=obj, id='admin.E029')
... | [
"def",
"_check_prepopulated_fields_value",
"(",
"self",
",",
"obj",
",",
"model",
",",
"val",
",",
"label",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
","... | [
411,
4
] | [
421,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields_value_item | (self, obj, model, field_name, label) | For `prepopulated_fields` equal to {"slug": ("title",)},
`field_name` is "title". | For `prepopulated_fields` equal to {"slug": ("title",)},
`field_name` is "title". | def _check_prepopulated_fields_value_item(self, obj, model, field_name, label):
""" For `prepopulated_fields` equal to {"slug": ("title",)},
`field_name` is "title". """
try:
model._meta.get_field(field_name)
except FieldDoesNotExist:
return refer_to_missing_fiel... | [
"def",
"_check_prepopulated_fields_value_item",
"(",
"self",
",",
"obj",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"return",
"refer_... | [
423,
4
] | [
432,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_ordering | (self, obj) | Check that ordering refers to existing fields or is random. | Check that ordering refers to existing fields or is random. | def _check_ordering(self, obj):
""" Check that ordering refers to existing fields or is random. """
# ordering = None
if obj.ordering is None: # The default value is None
return []
elif not isinstance(obj.ordering, (list, tuple)):
return must_be('a list or tuple... | [
"def",
"_check_ordering",
"(",
"self",
",",
"obj",
")",
":",
"# ordering = None",
"if",
"obj",
".",
"ordering",
"is",
"None",
":",
"# The default value is None",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"ordering",
",",
"(",
"list",
... | [
434,
4
] | [
446,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_ordering_item | (self, obj, model, field_name, label) | Check that `ordering` refers to existing fields. | Check that `ordering` refers to existing fields. | def _check_ordering_item(self, obj, model, field_name, label):
""" Check that `ordering` refers to existing fields. """
if field_name == '?' and len(obj.ordering) != 1:
return [
checks.Error(
"The value of 'ordering' has the random ordering marker '?', "
... | [
"def",
"_check_ordering_item",
"(",
"self",
",",
"obj",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"if",
"field_name",
"==",
"'?'",
"and",
"len",
"(",
"obj",
".",
"ordering",
")",
"!=",
"1",
":",
"return",
"[",
"checks",
".",
"Error",
"... | [
448,
4
] | [
477,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_readonly_fields | (self, obj) | Check that readonly_fields refers to proper attribute or field. | Check that readonly_fields refers to proper attribute or field. | def _check_readonly_fields(self, obj):
""" Check that readonly_fields refers to proper attribute or field. """
if obj.readonly_fields == ():
return []
elif not isinstance(obj.readonly_fields, (list, tuple)):
return must_be('a list or tuple', option='readonly_fields', obj... | [
"def",
"_check_readonly_fields",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
".",
"readonly_fields",
"==",
"(",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"obj",
".",
"readonly_fields",
",",
"(",
"list",
",",
"tuple",
")",
")",... | [
479,
4
] | [
490,
15
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_save_as | (self, obj) | Check save_as is a boolean. | Check save_as is a boolean. | def _check_save_as(self, obj):
""" Check save_as is a boolean. """
if not isinstance(obj.save_as, bool):
return must_be('a boolean', option='save_as',
obj=obj, id='admin.E101')
else:
return [] | [
"def",
"_check_save_as",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
".",
"save_as",
",",
"bool",
")",
":",
"return",
"must_be",
"(",
"'a boolean'",
",",
"option",
"=",
"'save_as'",
",",
"obj",
"=",
"obj",
",",
"id",
"="... | [
534,
4
] | [
541,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_save_on_top | (self, obj) | Check save_on_top is a boolean. | Check save_on_top is a boolean. | def _check_save_on_top(self, obj):
""" Check save_on_top is a boolean. """
if not isinstance(obj.save_on_top, bool):
return must_be('a boolean', option='save_on_top',
obj=obj, id='admin.E102')
else:
return [] | [
"def",
"_check_save_on_top",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
".",
"save_on_top",
",",
"bool",
")",
":",
"return",
"must_be",
"(",
"'a boolean'",
",",
"option",
"=",
"'save_on_top'",
",",
"obj",
"=",
"obj",
",",
... | [
543,
4
] | [
550,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_inlines | (self, obj) | Check all inline model admin classes. | Check all inline model admin classes. | def _check_inlines(self, obj):
""" Check all inline model admin classes. """
if not isinstance(obj.inlines, (list, tuple)):
return must_be('a list or tuple', option='inlines', obj=obj, id='admin.E103')
else:
return list(chain(*[
self._check_inlines_item(o... | [
"def",
"_check_inlines",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
".",
"inlines",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",
"'inlines'",
",",
"obj"... | [
552,
4
] | [
561,
15
] | python | en | ['sv', 'it', 'en'] | False |
ModelAdminChecks._check_inlines_item | (self, obj, model, inline, label) | Check one inline model admin. | Check one inline model admin. | def _check_inlines_item(self, obj, model, inline, label):
""" Check one inline model admin. """
inline_label = '.'.join([inline.__module__, inline.__name__])
from django.contrib.admin.options import InlineModelAdmin
if not issubclass(inline, InlineModelAdmin):
return [
... | [
"def",
"_check_inlines_item",
"(",
"self",
",",
"obj",
",",
"model",
",",
"inline",
",",
"label",
")",
":",
"inline_label",
"=",
"'.'",
".",
"join",
"(",
"[",
"inline",
".",
"__module__",
",",
"inline",
".",
"__name__",
"]",
")",
"from",
"django",
".",... | [
563,
4
] | [
588,
56
] | python | en | ['es', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.