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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
BaseModelAdmin.get_ordering | (self, request) |
Hook for specifying field ordering.
|
Hook for specifying field ordering.
| def get_ordering(self, request):
"""
Hook for specifying field ordering.
"""
return self.ordering or () | [
"def",
"get_ordering",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"ordering",
"or",
"(",
")"
] | [
342,
4
] | [
346,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_readonly_fields | (self, request, obj=None) |
Hook for specifying custom readonly fields.
|
Hook for specifying custom readonly fields.
| def get_readonly_fields(self, request, obj=None):
"""
Hook for specifying custom readonly fields.
"""
return self.readonly_fields | [
"def",
"get_readonly_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"readonly_fields"
] | [
348,
4
] | [
352,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_prepopulated_fields | (self, request, obj=None) |
Hook for specifying custom prepopulated fields.
|
Hook for specifying custom prepopulated fields.
| def get_prepopulated_fields(self, request, obj=None):
"""
Hook for specifying custom prepopulated fields.
"""
return self.prepopulated_fields | [
"def",
"get_prepopulated_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"prepopulated_fields"
] | [
354,
4
] | [
358,
39
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_queryset | (self, request) |
Return a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
|
Return a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
| def get_queryset(self, request):
"""
Return a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
"""
qs = self.model._default_manager.get_queryset()
# TODO: this should be handled by some parameter to the ChangeList.
... | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"self",
".",
"model",
".",
"_default_manager",
".",
"get_queryset",
"(",
")",
"# TODO: this should be handled by some parameter to the ChangeList.",
"ordering",
"=",
"self",
".",
"get_ordering",
... | [
360,
4
] | [
370,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_sortable_by | (self, request) | Hook for specifying which fields can be sorted in the changelist. | Hook for specifying which fields can be sorted in the changelist. | def get_sortable_by(self, request):
"""Hook for specifying which fields can be sorted in the changelist."""
return self.sortable_by if self.sortable_by is not None else self.get_list_display(request) | [
"def",
"get_sortable_by",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"sortable_by",
"if",
"self",
".",
"sortable_by",
"is",
"not",
"None",
"else",
"self",
".",
"get_list_display",
"(",
"request",
")"
] | [
372,
4
] | [
374,
99
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdmin.to_field_allowed | (self, request, to_field) |
Return True if the model associated with this admin should be
allowed to be referenced by the specified field.
|
Return True if the model associated with this admin should be
allowed to be referenced by the specified field.
| def to_field_allowed(self, request, to_field):
"""
Return True if the model associated with this admin should be
allowed to be referenced by the specified field.
"""
opts = self.model._meta
try:
field = opts.get_field(to_field)
except FieldDoesNotExis... | [
"def",
"to_field_allowed",
"(",
"self",
",",
"request",
",",
"to_field",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"try",
":",
"field",
"=",
"opts",
".",
"get_field",
"(",
"to_field",
")",
"except",
"FieldDoesNotExist",
":",
"return",
"F... | [
430,
4
] | [
473,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_add_permission | (self, request) |
Return True if the given request has permission to add an object.
Can be overridden by the user in subclasses.
|
Return True if the given request has permission to add an object.
Can be overridden by the user in subclasses.
| def has_add_permission(self, request):
"""
Return True if the given request has permission to add an object.
Can be overridden by the user in subclasses.
"""
opts = self.opts
codename = get_permission_codename('add', opts)
return request.user.has_perm("%s.%s" % (o... | [
"def",
"has_add_permission",
"(",
"self",
",",
"request",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename",
"=",
"get_permission_codename",
"(",
"'add'",
",",
"opts",
")",
"return",
"request",
".",
"user",
".",
"has_perm",
"(",
"\"%s.%s\"",
"%",
"(",... | [
475,
4
] | [
482,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_change_permission | (self, request, obj=None) |
Return True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to chan... |
Return True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter. | def has_change_permission(self, request, obj=None):
"""
Return True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
... | [
"def",
"has_change_permission",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename",
"=",
"get_permission_codename",
"(",
"'change'",
",",
"opts",
")",
"return",
"request",
".",
"user",
".",
"has_per... | [
484,
4
] | [
497,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_delete_permission | (self, request, obj=None) |
Return True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to dele... |
Return True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter. | def has_delete_permission(self, request, obj=None):
"""
Return True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
... | [
"def",
"has_delete_permission",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename",
"=",
"get_permission_codename",
"(",
"'delete'",
",",
"opts",
")",
"return",
"request",
".",
"user",
".",
"has_per... | [
499,
4
] | [
512,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_view_permission | (self, request, obj=None) |
Return True if the given request has permission to view the given
Django model instance. The default implementation doesn't examine the
`obj` parameter.
If overridden by the user in subclasses, it should return True if the
given request has permission to view the `obj` model in... |
Return True if the given request has permission to view the given
Django model instance. The default implementation doesn't examine the
`obj` parameter. | def has_view_permission(self, request, obj=None):
"""
Return True if the given request has permission to view the given
Django model instance. The default implementation doesn't examine the
`obj` parameter.
If overridden by the user in subclasses, it should return True if the
... | [
"def",
"has_view_permission",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename_view",
"=",
"get_permission_codename",
"(",
"'view'",
",",
"opts",
")",
"codename_change",
"=",
"get_permission_codename",
... | [
514,
4
] | [
531,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_module_permission | (self, request) |
Return True if the given request has any permission in the given
app label.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to view the module on
the admin index page and access the module's index page. Overrid... |
Return True if the given request has any permission in the given
app label. | def has_module_permission(self, request):
"""
Return True if the given request has any permission in the given
app label.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to view the module on
the admin i... | [
"def",
"has_module_permission",
"(",
"self",
",",
"request",
")",
":",
"return",
"request",
".",
"user",
".",
"has_module_perms",
"(",
"self",
".",
"opts",
".",
"app_label",
")"
] | [
536,
4
] | [
547,
65
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_model_perms | (self, request) |
Return a dict of all perms for this model. This dict has the keys
``add``, ``change``, ``delete``, and ``view`` mapping to the True/False
for each of those actions.
|
Return a dict of all perms for this model. This dict has the keys
``add``, ``change``, ``delete``, and ``view`` mapping to the True/False
for each of those actions.
| def get_model_perms(self, request):
"""
Return a dict of all perms for this model. This dict has the keys
``add``, ``change``, ``delete``, and ``view`` mapping to the True/False
for each of those actions.
"""
return {
'add': self.has_add_permission(request),
... | [
"def",
"get_model_perms",
"(",
"self",
",",
"request",
")",
":",
"return",
"{",
"'add'",
":",
"self",
".",
"has_add_permission",
"(",
"request",
")",
",",
"'change'",
":",
"self",
".",
"has_change_permission",
"(",
"request",
")",
",",
"'delete'",
":",
"se... | [
652,
4
] | [
663,
9
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_form | (self, request, obj=None, change=False, **kwargs) |
Return a Form class for use in the admin add view. This is used by
add_view and change_view.
|
Return a Form class for use in the admin add view. This is used by
add_view and change_view.
| def get_form(self, request, obj=None, change=False, **kwargs):
"""
Return a Form class for use in the admin add view. This is used by
add_view and change_view.
"""
if 'fields' in kwargs:
fields = kwargs.pop('fields')
else:
fields = flatten_fieldset... | [
"def",
"get_form",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"change",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'fields'",
"in",
"kwargs",
":",
"fields",
"=",
"kwargs",
".",
"pop",
"(",
"'fields'",
")",
"else",
":",
... | [
668,
4
] | [
714,
13
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_changelist | (self, request, **kwargs) |
Return the ChangeList class for use on the changelist page.
|
Return the ChangeList class for use on the changelist page.
| def get_changelist(self, request, **kwargs):
"""
Return the ChangeList class for use on the changelist page.
"""
from django.contrib.admin.views.main import ChangeList
return ChangeList | [
"def",
"get_changelist",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"views",
".",
"main",
"import",
"ChangeList",
"return",
"ChangeList"
] | [
716,
4
] | [
721,
25
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_changelist_instance | (self, request) |
Return a `ChangeList` instance based on `request`. May raise
`IncorrectLookupParameters`.
|
Return a `ChangeList` instance based on `request`. May raise
`IncorrectLookupParameters`.
| def get_changelist_instance(self, request):
"""
Return a `ChangeList` instance based on `request`. May raise
`IncorrectLookupParameters`.
"""
list_display = self.get_list_display(request)
list_display_links = self.get_list_display_links(request, list_display)
# Ad... | [
"def",
"get_changelist_instance",
"(",
"self",
",",
"request",
")",
":",
"list_display",
"=",
"self",
".",
"get_list_display",
"(",
"request",
")",
"list_display_links",
"=",
"self",
".",
"get_list_display_links",
"(",
"request",
",",
"list_display",
")",
"# Add t... | [
723,
4
] | [
749,
9
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_object | (self, request, object_id, from_field=None) |
Return an instance matching the field and value provided, the primary
key is used if no field is provided. Return ``None`` if no match is
found or the object_id fails validation.
|
Return an instance matching the field and value provided, the primary
key is used if no field is provided. Return ``None`` if no match is
found or the object_id fails validation.
| def get_object(self, request, object_id, from_field=None):
"""
Return an instance matching the field and value provided, the primary
key is used if no field is provided. Return ``None`` if no match is
found or the object_id fails validation.
"""
queryset = self.get_querys... | [
"def",
"get_object",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"from_field",
"=",
"None",
")",
":",
"queryset",
"=",
"self",
".",
"get_queryset",
"(",
"request",
")",
"model",
"=",
"queryset",
".",
"model",
"field",
"=",
"model",
".",
"_meta",
... | [
751,
4
] | [
764,
23
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_changelist_form | (self, request, **kwargs) |
Return a Form class for use in the Formset on the changelist page.
|
Return a Form class for use in the Formset on the changelist page.
| def get_changelist_form(self, request, **kwargs):
"""
Return a Form class for use in the Formset on the changelist page.
"""
defaults = {
'formfield_callback': partial(self.formfield_for_dbfield, request=request),
**kwargs,
}
if defaults.get('field... | [
"def",
"get_changelist_form",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'formfield_callback'",
":",
"partial",
"(",
"self",
".",
"formfield_for_dbfield",
",",
"request",
"=",
"request",
")",
",",
"*",
"*",
"kwar... | [
766,
4
] | [
777,
56
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_changelist_formset | (self, request, **kwargs) |
Return a FormSet class for use on the changelist page if list_editable
is used.
|
Return a FormSet class for use on the changelist page if list_editable
is used.
| def get_changelist_formset(self, request, **kwargs):
"""
Return a FormSet class for use on the changelist page if list_editable
is used.
"""
defaults = {
'formfield_callback': partial(self.formfield_for_dbfield, request=request),
**kwargs,
}
... | [
"def",
"get_changelist_formset",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'formfield_callback'",
":",
"partial",
"(",
"self",
".",
"formfield_for_dbfield",
",",
"request",
"=",
"request",
")",
",",
"*",
"*",
"k... | [
779,
4
] | [
791,
9
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_formsets_with_inlines | (self, request, obj=None) |
Yield formsets and the corresponding inlines.
|
Yield formsets and the corresponding inlines.
| def get_formsets_with_inlines(self, request, obj=None):
"""
Yield formsets and the corresponding inlines.
"""
for inline in self.get_inline_instances(request, obj):
yield inline.get_formset(request, obj), inline | [
"def",
"get_formsets_with_inlines",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"for",
"inline",
"in",
"self",
".",
"get_inline_instances",
"(",
"request",
",",
"obj",
")",
":",
"yield",
"inline",
".",
"get_formset",
"(",
"request",
","... | [
793,
4
] | [
798,
58
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.log_addition | (self, request, object, message) |
Log that an object has been successfully added.
The default implementation creates an admin LogEntry object.
|
Log that an object has been successfully added. | def log_addition(self, request, object, message):
"""
Log that an object has been successfully added.
The default implementation creates an admin LogEntry object.
"""
from django.contrib.admin.models import ADDITION, LogEntry
return LogEntry.objects.log_action(
... | [
"def",
"log_addition",
"(",
"self",
",",
"request",
",",
"object",
",",
"message",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"models",
"import",
"ADDITION",
",",
"LogEntry",
"return",
"LogEntry",
".",
"objects",
".",
"log_action",
"(",... | [
803,
4
] | [
817,
9
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.log_change | (self, request, object, message) |
Log that an object has been successfully changed.
The default implementation creates an admin LogEntry object.
|
Log that an object has been successfully changed. | def log_change(self, request, object, message):
"""
Log that an object has been successfully changed.
The default implementation creates an admin LogEntry object.
"""
from django.contrib.admin.models import CHANGE, LogEntry
return LogEntry.objects.log_action(
... | [
"def",
"log_change",
"(",
"self",
",",
"request",
",",
"object",
",",
"message",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"models",
"import",
"CHANGE",
",",
"LogEntry",
"return",
"LogEntry",
".",
"objects",
".",
"log_action",
"(",
"... | [
819,
4
] | [
833,
9
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.log_deletion | (self, request, object, object_repr) |
Log that an object will be deleted. Note that this method must be
called before the deletion.
The default implementation creates an admin LogEntry object.
|
Log that an object will be deleted. Note that this method must be
called before the deletion. | def log_deletion(self, request, object, object_repr):
"""
Log that an object will be deleted. Note that this method must be
called before the deletion.
The default implementation creates an admin LogEntry object.
"""
from django.contrib.admin.models import DELETION, LogE... | [
"def",
"log_deletion",
"(",
"self",
",",
"request",
",",
"object",
",",
"object_repr",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"models",
"import",
"DELETION",
",",
"LogEntry",
"return",
"LogEntry",
".",
"objects",
".",
"log_action",
... | [
835,
4
] | [
849,
9
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.action_checkbox | (self, obj) |
A list_display column containing a checkbox widget.
|
A list_display column containing a checkbox widget.
| def action_checkbox(self, obj):
"""
A list_display column containing a checkbox widget.
"""
return helpers.checkbox.render(helpers.ACTION_CHECKBOX_NAME, str(obj.pk)) | [
"def",
"action_checkbox",
"(",
"self",
",",
"obj",
")",
":",
"return",
"helpers",
".",
"checkbox",
".",
"render",
"(",
"helpers",
".",
"ACTION_CHECKBOX_NAME",
",",
"str",
"(",
"obj",
".",
"pk",
")",
")"
] | [
852,
4
] | [
856,
81
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._get_base_actions | (self) | Return the list of actions, prior to any request-based filtering. | Return the list of actions, prior to any request-based filtering. | def _get_base_actions(self):
"""Return the list of actions, prior to any request-based filtering."""
actions = []
base_actions = (self.get_action(action) for action in self.actions or [])
# get_action might have returned None, so filter any of those out.
base_actions = [action fo... | [
"def",
"_get_base_actions",
"(",
"self",
")",
":",
"actions",
"=",
"[",
"]",
"base_actions",
"=",
"(",
"self",
".",
"get_action",
"(",
"action",
")",
"for",
"action",
"in",
"self",
".",
"actions",
"or",
"[",
"]",
")",
"# get_action might have returned None, ... | [
862,
4
] | [
878,
22
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin._filter_actions_by_permissions | (self, request, actions) | Filter out any actions that the user doesn't have access to. | Filter out any actions that the user doesn't have access to. | def _filter_actions_by_permissions(self, request, actions):
"""Filter out any actions that the user doesn't have access to."""
filtered_actions = []
for action in actions:
callable = action[0]
if not hasattr(callable, 'allowed_permissions'):
filtered_actio... | [
"def",
"_filter_actions_by_permissions",
"(",
"self",
",",
"request",
",",
"actions",
")",
":",
"filtered_actions",
"=",
"[",
"]",
"for",
"action",
"in",
"actions",
":",
"callable",
"=",
"action",
"[",
"0",
"]",
"if",
"not",
"hasattr",
"(",
"callable",
","... | [
880,
4
] | [
894,
31
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin.get_actions | (self, request) |
Return a dictionary mapping the names of all actions for this
ModelAdmin to a tuple of (callable, name, description) for each action.
|
Return a dictionary mapping the names of all actions for this
ModelAdmin to a tuple of (callable, name, description) for each action.
| def get_actions(self, request):
"""
Return a dictionary mapping the names of all actions for this
ModelAdmin to a tuple of (callable, name, description) for each action.
"""
# If self.actions is set to None that means actions are disabled on
# this page.
if self.a... | [
"def",
"get_actions",
"(",
"self",
",",
"request",
")",
":",
"# If self.actions is set to None that means actions are disabled on",
"# this page.",
"if",
"self",
".",
"actions",
"is",
"None",
"or",
"IS_POPUP_VAR",
"in",
"request",
".",
"GET",
":",
"return",
"{",
"}"... | [
896,
4
] | [
906,
73
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_action_choices | (self, request, default_choices=models.BLANK_CHOICE_DASH) |
Return a list of choices for use in a form object. Each choice is a
tuple (name, description).
|
Return a list of choices for use in a form object. Each choice is a
tuple (name, description).
| def get_action_choices(self, request, default_choices=models.BLANK_CHOICE_DASH):
"""
Return a list of choices for use in a form object. Each choice is a
tuple (name, description).
"""
choices = [] + default_choices
for func, name, description in self.get_actions(request)... | [
"def",
"get_action_choices",
"(",
"self",
",",
"request",
",",
"default_choices",
"=",
"models",
".",
"BLANK_CHOICE_DASH",
")",
":",
"choices",
"=",
"[",
"]",
"+",
"default_choices",
"for",
"func",
",",
"name",
",",
"description",
"in",
"self",
".",
"get_act... | [
908,
4
] | [
917,
22
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_action | (self, action) |
Return a given action from a parameter, which can either be a callable,
or the name of a method on the ModelAdmin. Return is a tuple of
(callable, name, description).
|
Return a given action from a parameter, which can either be a callable,
or the name of a method on the ModelAdmin. Return is a tuple of
(callable, name, description).
| def get_action(self, action):
"""
Return a given action from a parameter, which can either be a callable,
or the name of a method on the ModelAdmin. Return is a tuple of
(callable, name, description).
"""
# If the action is a callable, just use it.
if callable(ac... | [
"def",
"get_action",
"(",
"self",
",",
"action",
")",
":",
"# If the action is a callable, just use it.",
"if",
"callable",
"(",
"action",
")",
":",
"func",
"=",
"action",
"action",
"=",
"action",
".",
"__name__",
"# Next, look for a method. Grab it off self.__class__ t... | [
919,
4
] | [
944,
40
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_list_display | (self, request) |
Return a sequence containing the fields to be displayed on the
changelist.
|
Return a sequence containing the fields to be displayed on the
changelist.
| def get_list_display(self, request):
"""
Return a sequence containing the fields to be displayed on the
changelist.
"""
return self.list_display | [
"def",
"get_list_display",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"list_display"
] | [
946,
4
] | [
951,
32
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_list_display_links | (self, request, list_display) |
Return a sequence containing the fields to be displayed as links
on the changelist. The list_display parameter is the list of fields
returned by get_list_display().
|
Return a sequence containing the fields to be displayed as links
on the changelist. The list_display parameter is the list of fields
returned by get_list_display().
| def get_list_display_links(self, request, list_display):
"""
Return a sequence containing the fields to be displayed as links
on the changelist. The list_display parameter is the list of fields
returned by get_list_display().
"""
if self.list_display_links or self.list_di... | [
"def",
"get_list_display_links",
"(",
"self",
",",
"request",
",",
"list_display",
")",
":",
"if",
"self",
".",
"list_display_links",
"or",
"self",
".",
"list_display_links",
"is",
"None",
"or",
"not",
"list_display",
":",
"return",
"self",
".",
"list_display_li... | [
953,
4
] | [
963,
41
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_list_filter | (self, request) |
Return a sequence containing the fields to be displayed as filters in
the right sidebar of the changelist page.
|
Return a sequence containing the fields to be displayed as filters in
the right sidebar of the changelist page.
| def get_list_filter(self, request):
"""
Return a sequence containing the fields to be displayed as filters in
the right sidebar of the changelist page.
"""
return self.list_filter | [
"def",
"get_list_filter",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"list_filter"
] | [
965,
4
] | [
970,
31
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_list_select_related | (self, request) |
Return a list of fields to add to the select_related() part of the
changelist items query.
|
Return a list of fields to add to the select_related() part of the
changelist items query.
| def get_list_select_related(self, request):
"""
Return a list of fields to add to the select_related() part of the
changelist items query.
"""
return self.list_select_related | [
"def",
"get_list_select_related",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"list_select_related"
] | [
972,
4
] | [
977,
39
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_search_fields | (self, request) |
Return a sequence containing the fields to be searched whenever
somebody submits a search query.
|
Return a sequence containing the fields to be searched whenever
somebody submits a search query.
| def get_search_fields(self, request):
"""
Return a sequence containing the fields to be searched whenever
somebody submits a search query.
"""
return self.search_fields | [
"def",
"get_search_fields",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"search_fields"
] | [
979,
4
] | [
984,
33
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_search_results | (self, request, queryset, search_term) |
Return a tuple containing a queryset to implement the search
and a boolean indicating if the results may contain duplicates.
|
Return a tuple containing a queryset to implement the search
and a boolean indicating if the results may contain duplicates.
| def get_search_results(self, request, queryset, search_term):
"""
Return a tuple containing a queryset to implement the search
and a boolean indicating if the results may contain duplicates.
"""
# Apply keyword searches.
def construct_search(field_name):
if fi... | [
"def",
"get_search_results",
"(",
"self",
",",
"request",
",",
"queryset",
",",
"search_term",
")",
":",
"# Apply keyword searches.",
"def",
"construct_search",
"(",
"field_name",
")",
":",
"if",
"field_name",
".",
"startswith",
"(",
"'^'",
")",
":",
"return",
... | [
986,
4
] | [
1036,
44
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_preserved_filters | (self, request) |
Return the preserved filters querystring.
|
Return the preserved filters querystring.
| def get_preserved_filters(self, request):
"""
Return the preserved filters querystring.
"""
match = request.resolver_match
if self.preserve_filters and match:
opts = self.model._meta
current_url = '%s:%s' % (match.app_name, match.url_name)
chan... | [
"def",
"get_preserved_filters",
"(",
"self",
",",
"request",
")",
":",
"match",
"=",
"request",
".",
"resolver_match",
"if",
"self",
".",
"preserve_filters",
"and",
"match",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"current_url",
"=",
"'%s:%s'",... | [
1038,
4
] | [
1054,
17
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.construct_change_message | (self, request, form, formsets, add=False) |
Construct a JSON structure describing changes from a changed object.
|
Construct a JSON structure describing changes from a changed object.
| def construct_change_message(self, request, form, formsets, add=False):
"""
Construct a JSON structure describing changes from a changed object.
"""
return construct_change_message(form, formsets, add) | [
"def",
"construct_change_message",
"(",
"self",
",",
"request",
",",
"form",
",",
"formsets",
",",
"add",
"=",
"False",
")",
":",
"return",
"construct_change_message",
"(",
"form",
",",
"formsets",
",",
"add",
")"
] | [
1056,
4
] | [
1060,
60
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.message_user | (self, request, message, level=messages.INFO, extra_tags='',
fail_silently=False) |
Send a message to the user. The default implementation
posts a message using the django.contrib.messages backend.
Exposes almost the same API as messages.add_message(), but accepts the
positional arguments in a different order to maintain backwards
compatibility. For convenienc... |
Send a message to the user. The default implementation
posts a message using the django.contrib.messages backend. | def message_user(self, request, message, level=messages.INFO, extra_tags='',
fail_silently=False):
"""
Send a message to the user. The default implementation
posts a message using the django.contrib.messages backend.
Exposes almost the same API as messages.add_messa... | [
"def",
"message_user",
"(",
"self",
",",
"request",
",",
"message",
",",
"level",
"=",
"messages",
".",
"INFO",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
... | [
1062,
4
] | [
1085,
105
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.save_form | (self, request, form, change) |
Given a ModelForm return an unsaved instance. ``change`` is True if
the object is being changed, and False if it's being added.
|
Given a ModelForm return an unsaved instance. ``change`` is True if
the object is being changed, and False if it's being added.
| def save_form(self, request, form, change):
"""
Given a ModelForm return an unsaved instance. ``change`` is True if
the object is being changed, and False if it's being added.
"""
return form.save(commit=False) | [
"def",
"save_form",
"(",
"self",
",",
"request",
",",
"form",
",",
"change",
")",
":",
"return",
"form",
".",
"save",
"(",
"commit",
"=",
"False",
")"
] | [
1087,
4
] | [
1092,
38
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.save_model | (self, request, obj, form, change) |
Given a model instance save it to the database.
|
Given a model instance save it to the database.
| def save_model(self, request, obj, form, change):
"""
Given a model instance save it to the database.
"""
obj.save() | [
"def",
"save_model",
"(",
"self",
",",
"request",
",",
"obj",
",",
"form",
",",
"change",
")",
":",
"obj",
".",
"save",
"(",
")"
] | [
1094,
4
] | [
1098,
18
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.delete_model | (self, request, obj) |
Given a model instance delete it from the database.
|
Given a model instance delete it from the database.
| def delete_model(self, request, obj):
"""
Given a model instance delete it from the database.
"""
obj.delete() | [
"def",
"delete_model",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"obj",
".",
"delete",
"(",
")"
] | [
1100,
4
] | [
1104,
20
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.delete_queryset | (self, request, queryset) | Given a queryset, delete it from the database. | Given a queryset, delete it from the database. | def delete_queryset(self, request, queryset):
"""Given a queryset, delete it from the database."""
queryset.delete() | [
"def",
"delete_queryset",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"queryset",
".",
"delete",
"(",
")"
] | [
1106,
4
] | [
1108,
25
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin.save_formset | (self, request, form, formset, change) |
Given an inline formset save it to the database.
|
Given an inline formset save it to the database.
| def save_formset(self, request, form, formset, change):
"""
Given an inline formset save it to the database.
"""
formset.save() | [
"def",
"save_formset",
"(",
"self",
",",
"request",
",",
"form",
",",
"formset",
",",
"change",
")",
":",
"formset",
".",
"save",
"(",
")"
] | [
1110,
4
] | [
1114,
22
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.save_related | (self, request, form, formsets, change) |
Given the ``HttpRequest``, the parent ``ModelForm`` instance, the
list of inline formsets and a boolean value based on whether the
parent is being added or changed, save the related objects to the
database. Note that at this point save_form() and save_model() have
already been c... |
Given the ``HttpRequest``, the parent ``ModelForm`` instance, the
list of inline formsets and a boolean value based on whether the
parent is being added or changed, save the related objects to the
database. Note that at this point save_form() and save_model() have
already been c... | def save_related(self, request, form, formsets, change):
"""
Given the ``HttpRequest``, the parent ``ModelForm`` instance, the
list of inline formsets and a boolean value based on whether the
parent is being added or changed, save the related objects to the
database. Note that at... | [
"def",
"save_related",
"(",
"self",
",",
"request",
",",
"form",
",",
"formsets",
",",
"change",
")",
":",
"form",
".",
"save_m2m",
"(",
")",
"for",
"formset",
"in",
"formsets",
":",
"self",
".",
"save_formset",
"(",
"request",
",",
"form",
",",
"forms... | [
1116,
4
] | [
1126,
68
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_add | (self, request, obj, post_url_continue=None) |
Determine the HttpResponse for the add_view stage.
|
Determine the HttpResponse for the add_view stage.
| def response_add(self, request, obj, post_url_continue=None):
"""
Determine the HttpResponse for the add_view stage.
"""
opts = obj._meta
preserved_filters = self.get_preserved_filters(request)
obj_url = reverse(
'admin:%s_%s_change' % (opts.app_label, opts.mo... | [
"def",
"response_add",
"(",
"self",
",",
"request",
",",
"obj",
",",
"post_url_continue",
"=",
"None",
")",
":",
"opts",
"=",
"obj",
".",
"_meta",
"preserved_filters",
"=",
"self",
".",
"get_preserved_filters",
"(",
"request",
")",
"obj_url",
"=",
"reverse",... | [
1175,
4
] | [
1250,
60
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_change | (self, request, obj) |
Determine the HttpResponse for the change_view stage.
|
Determine the HttpResponse for the change_view stage.
| def response_change(self, request, obj):
"""
Determine the HttpResponse for the change_view stage.
"""
if IS_POPUP_VAR in request.POST:
opts = obj._meta
to_field = request.POST.get(TO_FIELD_VAR)
attr = str(to_field) if to_field else opts.pk.attname
... | [
"def",
"response_change",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"if",
"IS_POPUP_VAR",
"in",
"request",
".",
"POST",
":",
"opts",
"=",
"obj",
".",
"_meta",
"to_field",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"TO_FIELD_VAR",
")",
"attr... | [
1252,
4
] | [
1325,
63
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_post_save_add | (self, request, obj) |
Figure out where to redirect after the 'Save' button has been pressed
when adding a new object.
|
Figure out where to redirect after the 'Save' button has been pressed
when adding a new object.
| def response_post_save_add(self, request, obj):
"""
Figure out where to redirect after the 'Save' button has been pressed
when adding a new object.
"""
return self._response_post_save(request, obj) | [
"def",
"response_post_save_add",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"return",
"self",
".",
"_response_post_save",
"(",
"request",
",",
"obj",
")"
] | [
1340,
4
] | [
1345,
53
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_post_save_change | (self, request, obj) |
Figure out where to redirect after the 'Save' button has been pressed
when editing an existing object.
|
Figure out where to redirect after the 'Save' button has been pressed
when editing an existing object.
| def response_post_save_change(self, request, obj):
"""
Figure out where to redirect after the 'Save' button has been pressed
when editing an existing object.
"""
return self._response_post_save(request, obj) | [
"def",
"response_post_save_change",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"return",
"self",
".",
"_response_post_save",
"(",
"request",
",",
"obj",
")"
] | [
1347,
4
] | [
1352,
53
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_action | (self, request, queryset) |
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
|
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
| def response_action(self, request, queryset):
"""
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
"""
# There can be multiple action forms on the page (at the top
... | [
"def",
"response_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"# There can be multiple action forms on the page (at the top",
"# and bottom of the change list, for example). Get the action",
"# whose button was pushed.",
"try",
":",
"action_index",
"=",
"int",
... | [
1354,
4
] | [
1419,
23
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_delete | (self, request, obj_display, obj_id) |
Determine the HttpResponse for the delete_view stage.
|
Determine the HttpResponse for the delete_view stage.
| def response_delete(self, request, obj_display, obj_id):
"""
Determine the HttpResponse for the delete_view stage.
"""
opts = self.model._meta
if IS_POPUP_VAR in request.POST:
popup_response_data = json.dumps({
'action': 'delete',
'val... | [
"def",
"response_delete",
"(",
"self",
",",
"request",
",",
"obj_display",
",",
"obj_id",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"if",
"IS_POPUP_VAR",
"in",
"request",
".",
"POST",
":",
"popup_response_data",
"=",
"json",
".",
"dumps",
... | [
1421,
4
] | [
1460,
45
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_changeform_initial_data | (self, request) |
Get the initial form data from the request's GET params.
|
Get the initial form data from the request's GET params.
| def get_changeform_initial_data(self, request):
"""
Get the initial form data from the request's GET params.
"""
initial = dict(request.GET.items())
for k in initial:
try:
f = self.model._meta.get_field(k)
except FieldDoesNotExist:
... | [
"def",
"get_changeform_initial_data",
"(",
"self",
",",
"request",
")",
":",
"initial",
"=",
"dict",
"(",
"request",
".",
"GET",
".",
"items",
"(",
")",
")",
"for",
"k",
"in",
"initial",
":",
"try",
":",
"f",
"=",
"self",
".",
"model",
".",
"_meta",
... | [
1508,
4
] | [
1521,
22
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._get_obj_does_not_exist_redirect | (self, request, opts, object_id) |
Create a message informing the user that the object doesn't exist
and return a redirect to the admin index page.
|
Create a message informing the user that the object doesn't exist
and return a redirect to the admin index page.
| def _get_obj_does_not_exist_redirect(self, request, opts, object_id):
"""
Create a message informing the user that the object doesn't exist
and return a redirect to the admin index page.
"""
msg = _('%(name)s with ID “%(key)s” doesn’t exist. Perhaps it was deleted?') % {
... | [
"def",
"_get_obj_does_not_exist_redirect",
"(",
"self",
",",
"request",
",",
"opts",
",",
"object_id",
")",
":",
"msg",
"=",
"_",
"(",
"'%(name)s with ID “%(key)s” doesn’t exist. Perhaps it was deleted?') % {",
"",
"",
"",
"'name'",
":",
"opts",
".",
"verbose_name",
... | [
1523,
4
] | [
1534,
40
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._get_edited_object_pks | (self, request, prefix) | Return POST data values of list_editable primary keys. | Return POST data values of list_editable primary keys. | def _get_edited_object_pks(self, request, prefix):
"""Return POST data values of list_editable primary keys."""
pk_pattern = re.compile(
r'{}-\d+-{}$'.format(re.escape(prefix), self.model._meta.pk.name)
)
return [value for key, value in request.POST.items() if pk_pattern.matc... | [
"def",
"_get_edited_object_pks",
"(",
"self",
",",
"request",
",",
"prefix",
")",
":",
"pk_pattern",
"=",
"re",
".",
"compile",
"(",
"r'{}-\\d+-{}$'",
".",
"format",
"(",
"re",
".",
"escape",
"(",
"prefix",
")",
",",
"self",
".",
"model",
".",
"_meta",
... | [
1661,
4
] | [
1666,
86
] | python | en | ['en', 'et', 'en'] | True |
ModelAdmin._get_list_editable_queryset | (self, request, prefix) |
Based on POST data, return a queryset of the objects that were edited
via list_editable.
|
Based on POST data, return a queryset of the objects that were edited
via list_editable.
| def _get_list_editable_queryset(self, request, prefix):
"""
Based on POST data, return a queryset of the objects that were edited
via list_editable.
"""
object_pks = self._get_edited_object_pks(request, prefix)
queryset = self.get_queryset(request)
validate = quer... | [
"def",
"_get_list_editable_queryset",
"(",
"self",
",",
"request",
",",
"prefix",
")",
":",
"object_pks",
"=",
"self",
".",
"_get_edited_object_pks",
"(",
"request",
",",
"prefix",
")",
"queryset",
"=",
"self",
".",
"get_queryset",
"(",
"request",
")",
"valida... | [
1668,
4
] | [
1682,
49
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.changelist_view | (self, request, extra_context=None) |
The 'change list' admin view for this model.
|
The 'change list' admin view for this model.
| def changelist_view(self, request, extra_context=None):
"""
The 'change list' admin view for this model.
"""
from django.contrib.admin.views.main import ERROR_FLAG
opts = self.model._meta
app_label = opts.app_label
if not self.has_view_or_change_permission(request... | [
"def",
"changelist_view",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"views",
".",
"main",
"import",
"ERROR_FLAG",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"app_l... | [
1685,
4
] | [
1838,
19
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_deleted_objects | (self, objs, request) |
Hook for customizing the delete process for the delete view and the
"delete selected" action.
|
Hook for customizing the delete process for the delete view and the
"delete selected" action.
| def get_deleted_objects(self, objs, request):
"""
Hook for customizing the delete process for the delete view and the
"delete selected" action.
"""
return get_deleted_objects(objs, request, self.admin_site) | [
"def",
"get_deleted_objects",
"(",
"self",
",",
"objs",
",",
"request",
")",
":",
"return",
"get_deleted_objects",
"(",
"objs",
",",
"request",
",",
"self",
".",
"admin_site",
")"
] | [
1840,
4
] | [
1845,
66
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._delete_view | (self, request, object_id, extra_context) | The 'delete' admin view for this model. | The 'delete' admin view for this model. | def _delete_view(self, request, object_id, extra_context):
"The 'delete' admin view for this model."
opts = self.model._meta
app_label = opts.app_label
to_field = request.POST.get(TO_FIELD_VAR, request.GET.get(TO_FIELD_VAR))
if to_field and not self.to_field_allowed(request, to_... | [
"def",
"_delete_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"app_label",
"=",
"opts",
".",
"app_label",
"to_field",
"=",
"request",
".",
"POST",
".",
"get",
"(",
... | [
1852,
4
] | [
1909,
56
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin.history_view | (self, request, object_id, extra_context=None) | The 'history' admin view for this model. | The 'history' admin view for this model. | def history_view(self, request, object_id, extra_context=None):
"The 'history' admin view for this model."
from django.contrib.admin.models import LogEntry
# First check if the user can see this history.
model = self.model
obj = self.get_object(request, unquote(object_id))
... | [
"def",
"history_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"models",
"import",
"LogEntry",
"# First check if the user can see this history.",
"model",
"=",... | [
1911,
4
] | [
1950,
19
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin._create_formsets | (self, request, obj, change) | Helper function to generate formsets for add/change_view. | Helper function to generate formsets for add/change_view. | def _create_formsets(self, request, obj, change):
"Helper function to generate formsets for add/change_view."
formsets = []
inline_instances = []
prefixes = {}
get_formsets_args = [request]
if change:
get_formsets_args.append(obj)
for FormSet, inline i... | [
"def",
"_create_formsets",
"(",
"self",
",",
"request",
",",
"obj",
",",
"change",
")",
":",
"formsets",
"=",
"[",
"]",
"inline_instances",
"=",
"[",
"]",
"prefixes",
"=",
"{",
"}",
"get_formsets_args",
"=",
"[",
"request",
"]",
"if",
"change",
":",
"g... | [
1952,
4
] | [
1995,
41
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_extra | (self, request, obj=None, **kwargs) | Hook for customizing the number of extra inline forms. | Hook for customizing the number of extra inline forms. | def get_extra(self, request, obj=None, **kwargs):
"""Hook for customizing the number of extra inline forms."""
return self.extra | [
"def",
"get_extra",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"extra"
] | [
2041,
4
] | [
2043,
25
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_min_num | (self, request, obj=None, **kwargs) | Hook for customizing the min number of inline forms. | Hook for customizing the min number of inline forms. | def get_min_num(self, request, obj=None, **kwargs):
"""Hook for customizing the min number of inline forms."""
return self.min_num | [
"def",
"get_min_num",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"min_num"
] | [
2045,
4
] | [
2047,
27
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_max_num | (self, request, obj=None, **kwargs) | Hook for customizing the max number of extra inline forms. | Hook for customizing the max number of extra inline forms. | def get_max_num(self, request, obj=None, **kwargs):
"""Hook for customizing the max number of extra inline forms."""
return self.max_num | [
"def",
"get_max_num",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"max_num"
] | [
2049,
4
] | [
2051,
27
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_formset | (self, request, obj=None, **kwargs) | Return a BaseInlineFormSet class for use in admin add/change views. | Return a BaseInlineFormSet class for use in admin add/change views. | def get_formset(self, request, obj=None, **kwargs):
"""Return a BaseInlineFormSet class for use in admin add/change views."""
if 'fields' in kwargs:
fields = kwargs.pop('fields')
else:
fields = flatten_fieldsets(self.get_fieldsets(request, obj))
excluded = self.ge... | [
"def",
"get_formset",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'fields'",
"in",
"kwargs",
":",
"fields",
"=",
"kwargs",
".",
"pop",
"(",
"'fields'",
")",
"else",
":",
"fields",
"=",
"flatten_fiel... | [
2053,
4
] | [
2140,
79
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin._has_any_perms_for_target_model | (self, request, perms) |
This method is called only when the ModelAdmin's model is for an
ManyToManyField's implicit through model (if self.opts.auto_created).
Return True if the user has any of the given permissions ('add',
'change', etc.) for the model that points to the through model.
|
This method is called only when the ModelAdmin's model is for an
ManyToManyField's implicit through model (if self.opts.auto_created).
Return True if the user has any of the given permissions ('add',
'change', etc.) for the model that points to the through model.
| def _has_any_perms_for_target_model(self, request, perms):
"""
This method is called only when the ModelAdmin's model is for an
ManyToManyField's implicit through model (if self.opts.auto_created).
Return True if the user has any of the given permissions ('add',
'change', etc.) f... | [
"def",
"_has_any_perms_for_target_model",
"(",
"self",
",",
"request",
",",
"perms",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"# Find the target model of an auto-created many-to-many relationship.",
"for",
"field",
"in",
"opts",
".",
"fields",
":",
"if",
"field",
... | [
2151,
4
] | [
2167,
9
] | python | en | ['en', 'error', 'th'] | False |
DictionaryStorage.__init__ | (self, dictionary, key, lock=None) | Construct a DictionaryStorage instance. | Construct a DictionaryStorage instance. | def __init__(self, dictionary, key, lock=None):
"""Construct a DictionaryStorage instance."""
super(DictionaryStorage, self).__init__(lock=lock)
self._dictionary = dictionary
self._key = key | [
"def",
"__init__",
"(",
"self",
",",
"dictionary",
",",
"key",
",",
"lock",
"=",
"None",
")",
":",
"super",
"(",
"DictionaryStorage",
",",
"self",
")",
".",
"__init__",
"(",
"lock",
"=",
"lock",
")",
"self",
".",
"_dictionary",
"=",
"dictionary",
"self... | [
31,
4
] | [
35,
23
] | python | en | ['en', 'en', 'en'] | True |
DictionaryStorage.locked_get | (self) | Retrieve the credentials from the dictionary, if they exist.
Returns: A :class:`oauth2client.client.OAuth2Credentials` instance.
| Retrieve the credentials from the dictionary, if they exist. | def locked_get(self):
"""Retrieve the credentials from the dictionary, if they exist.
Returns: A :class:`oauth2client.client.OAuth2Credentials` instance.
"""
serialized = self._dictionary.get(self._key)
if serialized is None:
return None
credentials = clien... | [
"def",
"locked_get",
"(",
"self",
")",
":",
"serialized",
"=",
"self",
".",
"_dictionary",
".",
"get",
"(",
"self",
".",
"_key",
")",
"if",
"serialized",
"is",
"None",
":",
"return",
"None",
"credentials",
"=",
"client",
".",
"OAuth2Credentials",
".",
"f... | [
37,
4
] | [
50,
26
] | python | en | ['en', 'en', 'en'] | True |
DictionaryStorage.locked_put | (self, credentials) | Save the credentials to the dictionary.
Args:
credentials: A :class:`oauth2client.client.OAuth2Credentials`
instance.
| Save the credentials to the dictionary. | def locked_put(self, credentials):
"""Save the credentials to the dictionary.
Args:
credentials: A :class:`oauth2client.client.OAuth2Credentials`
instance.
"""
serialized = credentials.to_json()
self._dictionary[self._key] = serialized | [
"def",
"locked_put",
"(",
"self",
",",
"credentials",
")",
":",
"serialized",
"=",
"credentials",
".",
"to_json",
"(",
")",
"self",
".",
"_dictionary",
"[",
"self",
".",
"_key",
"]",
"=",
"serialized"
] | [
52,
4
] | [
60,
48
] | python | en | ['en', 'en', 'en'] | True |
DictionaryStorage.locked_delete | (self) | Remove the credentials from the dictionary, if they exist. | Remove the credentials from the dictionary, if they exist. | def locked_delete(self):
"""Remove the credentials from the dictionary, if they exist."""
self._dictionary.pop(self._key, None) | [
"def",
"locked_delete",
"(",
"self",
")",
":",
"self",
".",
"_dictionary",
".",
"pop",
"(",
"self",
".",
"_key",
",",
"None",
")"
] | [
62,
4
] | [
64,
45
] | python | en | ['en', 'en', 'en'] | True |
TagMap.presentTypes | (self) | Return *TagSet* to ASN.1 type map present in callee *TagMap* | Return *TagSet* to ASN.1 type map present in callee *TagMap* | def presentTypes(self):
"""Return *TagSet* to ASN.1 type map present in callee *TagMap*"""
return self.__presentTypes | [
"def",
"presentTypes",
"(",
"self",
")",
":",
"return",
"self",
".",
"__presentTypes"
] | [
72,
4
] | [
74,
34
] | python | en | ['en', 'en', 'en'] | True |
TagMap.skipTypes | (self) | Return *TagSet* collection unconditionally absent in callee *TagMap* | Return *TagSet* collection unconditionally absent in callee *TagMap* | def skipTypes(self):
"""Return *TagSet* collection unconditionally absent in callee *TagMap*"""
return self.__skipTypes | [
"def",
"skipTypes",
"(",
"self",
")",
":",
"return",
"self",
".",
"__skipTypes"
] | [
77,
4
] | [
79,
31
] | python | en | ['en', 'en', 'en'] | True |
TagMap.defaultType | (self) | Return default ASN.1 type being returned for any missing *TagSet* | Return default ASN.1 type being returned for any missing *TagSet* | def defaultType(self):
"""Return default ASN.1 type being returned for any missing *TagSet*"""
return self.__defaultType | [
"def",
"defaultType",
"(",
"self",
")",
":",
"return",
"self",
".",
"__defaultType"
] | [
82,
4
] | [
84,
33
] | python | en | ['en', 'en', 'en'] | True |
describe_token | (token) | Returns a description of the token. | Returns a description of the token. | def describe_token(token):
"""Returns a description of the token."""
if token.type == 'name':
return token.value
return _describe_token_type(token.type) | [
"def",
"describe_token",
"(",
"token",
")",
":",
"if",
"token",
".",
"type",
"==",
"'name'",
":",
"return",
"token",
".",
"value",
"return",
"_describe_token_type",
"(",
"token",
".",
"type",
")"
] | [
170,
0
] | [
174,
43
] | python | en | ['en', 'gl', 'en'] | True |
describe_token_expr | (expr) | Like `describe_token` but for token expressions. | Like `describe_token` but for token expressions. | def describe_token_expr(expr):
"""Like `describe_token` but for token expressions."""
if ':' in expr:
type, value = expr.split(':', 1)
if type == 'name':
return value
else:
type = expr
return _describe_token_type(type) | [
"def",
"describe_token_expr",
"(",
"expr",
")",
":",
"if",
"':'",
"in",
"expr",
":",
"type",
",",
"value",
"=",
"expr",
".",
"split",
"(",
"':'",
",",
"1",
")",
"if",
"type",
"==",
"'name'",
":",
"return",
"value",
"else",
":",
"type",
"=",
"expr",... | [
177,
0
] | [
185,
37
] | python | en | ['en', 'en', 'en'] | True |
count_newlines | (value) | Count the number of newline characters in the string. This is
useful for extensions that filter a stream.
| Count the number of newline characters in the string. This is
useful for extensions that filter a stream.
| def count_newlines(value):
"""Count the number of newline characters in the string. This is
useful for extensions that filter a stream.
"""
return len(newline_re.findall(value)) | [
"def",
"count_newlines",
"(",
"value",
")",
":",
"return",
"len",
"(",
"newline_re",
".",
"findall",
"(",
"value",
")",
")"
] | [
188,
0
] | [
192,
41
] | python | en | ['en', 'en', 'en'] | True |
compile_rules | (environment) | Compiles all the rules from the environment into a list of rules. | Compiles all the rules from the environment into a list of rules. | def compile_rules(environment):
"""Compiles all the rules from the environment into a list of rules."""
e = re.escape
rules = [
(len(environment.comment_start_string), 'comment',
e(environment.comment_start_string)),
(len(environment.block_start_string), 'block',
e(environm... | [
"def",
"compile_rules",
"(",
"environment",
")",
":",
"e",
"=",
"re",
".",
"escape",
"rules",
"=",
"[",
"(",
"len",
"(",
"environment",
".",
"comment_start_string",
")",
",",
"'comment'",
",",
"e",
"(",
"environment",
".",
"comment_start_string",
")",
")",... | [
195,
0
] | [
215,
55
] | python | en | ['en', 'en', 'en'] | True |
get_lexer | (environment) | Return a lexer which is probably cached. | Return a lexer which is probably cached. | def get_lexer(environment):
"""Return a lexer which is probably cached."""
key = (environment.block_start_string,
environment.block_end_string,
environment.variable_start_string,
environment.variable_end_string,
environment.comment_start_string,
environment... | [
"def",
"get_lexer",
"(",
"environment",
")",
":",
"key",
"=",
"(",
"environment",
".",
"block_start_string",
",",
"environment",
".",
"block_end_string",
",",
"environment",
".",
"variable_start_string",
",",
"environment",
".",
"variable_end_string",
",",
"environm... | [
390,
0
] | [
408,
16
] | python | en | ['en', 'en', 'en'] | True |
Token.test | (self, expr) | Test a token against a token expression. This can either be a
token type or ``'token_type:token_value'``. This can only test
against string values and types.
| Test a token against a token expression. This can either be a
token type or ``'token_type:token_value'``. This can only test
against string values and types.
| def test(self, expr):
"""Test a token against a token expression. This can either be a
token type or ``'token_type:token_value'``. This can only test
against string values and types.
"""
# here we do a regular string equality check as test_any is usually
# passed an ite... | [
"def",
"test",
"(",
"self",
",",
"expr",
")",
":",
"# here we do a regular string equality check as test_any is usually",
"# passed an iterable of not interned strings.",
"if",
"self",
".",
"type",
"==",
"expr",
":",
"return",
"True",
"elif",
"':'",
"in",
"expr",
":",
... | [
246,
4
] | [
257,
20
] | python | en | ['en', 'en', 'en'] | True |
Token.test_any | (self, *iterable) | Test against multiple token expressions. | Test against multiple token expressions. | def test_any(self, *iterable):
"""Test against multiple token expressions."""
for expr in iterable:
if self.test(expr):
return True
return False | [
"def",
"test_any",
"(",
"self",
",",
"*",
"iterable",
")",
":",
"for",
"expr",
"in",
"iterable",
":",
"if",
"self",
".",
"test",
"(",
"expr",
")",
":",
"return",
"True",
"return",
"False"
] | [
259,
4
] | [
264,
20
] | python | en | ['nl', 'en', 'en'] | True |
Lexer._normalize_newlines | (self, value) | Called for strings and template data to normalize it to unicode. | Called for strings and template data to normalize it to unicode. | def _normalize_newlines(self, value):
"""Called for strings and template data to normalize it to unicode."""
return newline_re.sub(self.newline_sequence, value) | [
"def",
"_normalize_newlines",
"(",
"self",
",",
"value",
")",
":",
"return",
"newline_re",
".",
"sub",
"(",
"self",
".",
"newline_sequence",
",",
"value",
")"
] | [
547,
4
] | [
549,
59
] | python | en | ['en', 'en', 'en'] | True |
Lexer.tokenize | (self, source, name=None, filename=None, state=None) | Calls tokeniter + tokenize and wraps it in a token stream.
| Calls tokeniter + tokenize and wraps it in a token stream.
| def tokenize(self, source, name=None, filename=None, state=None):
"""Calls tokeniter + tokenize and wraps it in a token stream.
"""
stream = self.tokeniter(source, name, filename, state)
return TokenStream(self.wrap(stream, name, filename), name, filename) | [
"def",
"tokenize",
"(",
"self",
",",
"source",
",",
"name",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"state",
"=",
"None",
")",
":",
"stream",
"=",
"self",
".",
"tokeniter",
"(",
"source",
",",
"name",
",",
"filename",
",",
"state",
")",
"re... | [
551,
4
] | [
555,
77
] | python | en | ['en', 'en', 'en'] | True |
Lexer.wrap | (self, stream, name=None, filename=None) | This is called with the stream as returned by `tokenize` and wraps
every token in a :class:`Token` and converts the value.
| This is called with the stream as returned by `tokenize` and wraps
every token in a :class:`Token` and converts the value.
| def wrap(self, stream, name=None, filename=None):
"""This is called with the stream as returned by `tokenize` and wraps
every token in a :class:`Token` and converts the value.
"""
for lineno, token, value in stream:
if token in ignored_tokens:
continue
... | [
"def",
"wrap",
"(",
"self",
",",
"stream",
",",
"name",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"for",
"lineno",
",",
"token",
",",
"value",
"in",
"stream",
":",
"if",
"token",
"in",
"ignored_tokens",
":",
"continue",
"elif",
"token",
"=... | [
557,
4
] | [
596,
45
] | python | en | ['en', 'en', 'en'] | True |
Lexer.tokeniter | (self, source, name, filename=None, state=None) | This method tokenizes the text and returns the tokens in a
generator. Use this method if you just want to tokenize a template.
| This method tokenizes the text and returns the tokens in a
generator. Use this method if you just want to tokenize a template.
| def tokeniter(self, source, name, filename=None, state=None):
"""This method tokenizes the text and returns the tokens in a
generator. Use this method if you just want to tokenize a template.
"""
source = text_type(source)
lines = source.splitlines()
if self.keep_trailin... | [
"def",
"tokeniter",
"(",
"self",
",",
"source",
",",
"name",
",",
"filename",
"=",
"None",
",",
"state",
"=",
"None",
")",
":",
"source",
"=",
"text_type",
"(",
"source",
")",
"lines",
"=",
"source",
".",
"splitlines",
"(",
")",
"if",
"self",
".",
... | [
598,
4
] | [
738,
57
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.__init__ | (
self,
*,
host: str = "monitoring.googleapis.com",
credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
api_mtls_endpoint: str = None,
client_cert_source: Callabl... | Instantiate the transport.
Args:
host (Optional[str]):
The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the applicatio... | Instantiate the transport. | def __init__(
self,
*,
host: str = "monitoring.googleapis.com",
credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
api_mtls_endpoint: str = None,
client_cert_sou... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"host",
":",
"str",
"=",
"\"monitoring.googleapis.com\"",
",",
"credentials",
":",
"ga_credentials",
".",
"Credentials",
"=",
"None",
",",
"credentials_file",
":",
"str",
"=",
"None",
",",
"scopes",
":",
"Sequen... | [
48,
4
] | [
175,
48
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.create_channel | (
cls,
host: str = "monitoring.googleapis.com",
credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs,
) | Create and return a gRPC channel object.
Args:
host (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If... | Create and return a gRPC channel object.
Args:
host (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If... | def create_channel(
cls,
host: str = "monitoring.googleapis.com",
credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs,
) -> grpc.Channel:
... | [
"def",
"create_channel",
"(",
"cls",
",",
"host",
":",
"str",
"=",
"\"monitoring.googleapis.com\"",
",",
"credentials",
":",
"ga_credentials",
".",
"Credentials",
"=",
"None",
",",
"credentials_file",
":",
"str",
"=",
"None",
",",
"scopes",
":",
"Optional",
"[... | [
178,
4
] | [
222,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.grpc_channel | (self) | Return the channel designed to connect to this service.
| Return the channel designed to connect to this service.
| def grpc_channel(self) -> grpc.Channel:
"""Return the channel designed to connect to this service.
"""
return self._grpc_channel | [
"def",
"grpc_channel",
"(",
"self",
")",
"->",
"grpc",
".",
"Channel",
":",
"return",
"self",
".",
"_grpc_channel"
] | [
225,
4
] | [
228,
33
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.create_dashboard | (
self,
) | r"""Return a callable for the create dashboard method over gRPC.
Creates a new custom dashboard. For examples on how you can use
this API to create dashboards, see `Managing dashboards by
API <https://cloud.google.com/monitoring/dashboards/api-dashboard>`__.
This method requires the ``m... | r"""Return a callable for the create dashboard method over gRPC. | def create_dashboard(
self,
) -> Callable[[dashboards_service.CreateDashboardRequest], dashboard.Dashboard]:
r"""Return a callable for the create dashboard method over gRPC.
Creates a new custom dashboard. For examples on how you can use
this API to create dashboards, see `Managing ... | [
"def",
"create_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"CreateDashboardRequest",
"]",
",",
"dashboard",
".",
"Dashboard",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"#... | [
231,
4
] | [
260,
46
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.list_dashboards | (
self,
) | r"""Return a callable for the list dashboards method over gRPC.
Lists the existing dashboards.
This method requires the ``monitoring.dashboards.list``
permission on the specified project. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/... | r"""Return a callable for the list dashboards method over gRPC. | def list_dashboards(
self,
) -> Callable[
[dashboards_service.ListDashboardsRequest],
dashboards_service.ListDashboardsResponse,
]:
r"""Return a callable for the list dashboards method over gRPC.
Lists the existing dashboards.
This method requires the ``monitori... | [
"def",
"list_dashboards",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"ListDashboardsRequest",
"]",
",",
"dashboards_service",
".",
"ListDashboardsResponse",
",",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make... | [
263,
4
] | [
294,
45
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.get_dashboard | (
self,
) | r"""Return a callable for the get dashboard method over gRPC.
Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud.google.com/ia... | r"""Return a callable for the get dashboard method over gRPC. | def get_dashboard(
self,
) -> Callable[[dashboards_service.GetDashboardRequest], dashboard.Dashboard]:
r"""Return a callable for the get dashboard method over gRPC.
Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specif... | [
"def",
"get_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"GetDashboardRequest",
"]",
",",
"dashboard",
".",
"Dashboard",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"# gRPC ... | [
297,
4
] | [
325,
43
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.delete_dashboard | (
self,
) | r"""Return a callable for the delete dashboard method over gRPC.
Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Management <https://cloud... | r"""Return a callable for the delete dashboard method over gRPC. | def delete_dashboard(
self,
) -> Callable[[dashboards_service.DeleteDashboardRequest], empty_pb2.Empty]:
r"""Return a callable for the delete dashboard method over gRPC.
Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permissi... | [
"def",
"delete_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"DeleteDashboardRequest",
"]",
",",
"empty_pb2",
".",
"Empty",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"# gRP... | [
328,
4
] | [
356,
46
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.update_dashboard | (
self,
) | r"""Return a callable for the update dashboard method over gRPC.
Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboards.update``
permission on the specified dashboard. For more information, see
`Cloud Identity and Access
Ma... | r"""Return a callable for the update dashboard method over gRPC. | def update_dashboard(
self,
) -> Callable[[dashboards_service.UpdateDashboardRequest], dashboard.Dashboard]:
r"""Return a callable for the update dashboard method over gRPC.
Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboard... | [
"def",
"update_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"UpdateDashboardRequest",
"]",
",",
"dashboard",
".",
"Dashboard",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"#... | [
359,
4
] | [
387,
46
] | python | en | ['en', 'en', 'en'] | True |
write_to_stdout | (data) | Writes bytes to stdout
:type data: bytes
| Writes bytes to stdout | def write_to_stdout(data):
"""Writes bytes to stdout
:type data: bytes
"""
if PY2:
sys.stdout.write(data)
else:
# On Py3 we must use the buffer interface to write bytes.
sys.stdout.buffer.write(data) | [
"def",
"write_to_stdout",
"(",
"data",
")",
":",
"if",
"PY2",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"data",
")",
"else",
":",
"# On Py3 we must use the buffer interface to write bytes.",
"sys",
".",
"stdout",
".",
"buffer",
".",
"write",
"(",
"data",
... | [
52,
0
] | [
61,
37
] | python | en | ['en', 'el-Latn', 'en'] | True |
is_bytes | (obj) |
Determines whether the given value is a byte string.
:param obj:
The value to test.
:returns:
``True`` if ``value`` is a byte string; ``False`` otherwise.
|
Determines whether the given value is a byte string. | def is_bytes(obj):
"""
Determines whether the given value is a byte string.
:param obj:
The value to test.
:returns:
``True`` if ``value`` is a byte string; ``False`` otherwise.
"""
return isinstance(obj, bytes) | [
"def",
"is_bytes",
"(",
"obj",
")",
":",
"return",
"isinstance",
"(",
"obj",
",",
"bytes",
")"
] | [
64,
0
] | [
73,
33
] | python | en | ['en', 'error', 'th'] | False |
is_integer | (obj) |
Determines whether the given value is an integer.
:param obj:
The value to test.
:returns:
``True`` if ``value`` is an integer; ``False`` otherwise.
|
Determines whether the given value is an integer. | def is_integer(obj):
"""
Determines whether the given value is an integer.
:param obj:
The value to test.
:returns:
``True`` if ``value`` is an integer; ``False`` otherwise.
"""
return isinstance(obj, integer_types) | [
"def",
"is_integer",
"(",
"obj",
")",
":",
"return",
"isinstance",
"(",
"obj",
",",
"integer_types",
")"
] | [
76,
0
] | [
85,
41
] | python | en | ['en', 'error', 'th'] | False |
byte | (num) |
Converts a number between 0 and 255 (both inclusive) to a base-256 (byte)
representation.
Use it as a replacement for ``chr`` where you are expecting a byte
because this will work on all current versions of Python::
:param num:
An unsigned integer between 0 and 255 (both inclusive).
:... |
Converts a number between 0 and 255 (both inclusive) to a base-256 (byte)
representation. | def byte(num):
"""
Converts a number between 0 and 255 (both inclusive) to a base-256 (byte)
representation.
Use it as a replacement for ``chr`` where you are expecting a byte
because this will work on all current versions of Python::
:param num:
An unsigned integer between 0 and 255 (... | [
"def",
"byte",
"(",
"num",
")",
":",
"return",
"pack",
"(",
"\"B\"",
",",
"num",
")"
] | [
88,
0
] | [
101,
25
] | python | en | ['en', 'error', 'th'] | False |
xor_bytes | (b1, b2) |
Returns the bitwise XOR result between two bytes objects, b1 ^ b2.
Bitwise XOR operation is commutative, so order of parameters doesn't
generate different results. If parameters have different length, extra
length of the largest one is ignored.
:param b1:
First bytes object.
:param b2... |
Returns the bitwise XOR result between two bytes objects, b1 ^ b2. | def xor_bytes(b1, b2):
"""
Returns the bitwise XOR result between two bytes objects, b1 ^ b2.
Bitwise XOR operation is commutative, so order of parameters doesn't
generate different results. If parameters have different length, extra
length of the largest one is ignored.
:param b1:
Fir... | [
"def",
"xor_bytes",
"(",
"b1",
",",
"b2",
")",
":",
"if",
"PY2",
":",
"return",
"''",
".",
"join",
"(",
"byte",
"(",
"ord",
"(",
"x",
")",
"^",
"ord",
"(",
"y",
")",
")",
"for",
"x",
",",
"y",
"in",
"zip",
"(",
"b1",
",",
"b2",
")",
")",
... | [
104,
0
] | [
122,
47
] | python | en | ['en', 'error', 'th'] | False |
get_word_alignment | (num, force_arch=64,
_machine_word_size=MACHINE_WORD_SIZE) |
Returns alignment details for the given number based on the platform
Python is running on.
:param num:
Unsigned integral number.
:param force_arch:
If you don't want to use 64-bit unsigned chunks, set this to
anything other than 64. 32-bit chunks will be preferred then.
... |
Returns alignment details for the given number based on the platform
Python is running on. | def get_word_alignment(num, force_arch=64,
_machine_word_size=MACHINE_WORD_SIZE):
"""
Returns alignment details for the given number based on the platform
Python is running on.
:param num:
Unsigned integral number.
:param force_arch:
If you don't want to use 6... | [
"def",
"get_word_alignment",
"(",
"num",
",",
"force_arch",
"=",
"64",
",",
"_machine_word_size",
"=",
"MACHINE_WORD_SIZE",
")",
":",
"max_uint64",
"=",
"0xffffffffffffffff",
"max_uint32",
"=",
"0xffffffff",
"max_uint16",
"=",
"0xffff",
"max_uint8",
"=",
"0xff",
"... | [
125,
0
] | [
161,
35
] | python | en | ['en', 'error', 'th'] | False |
get_feature | (name) | Get an instance of a ``Features`` class by ``name`` (str). | Get an instance of a ``Features`` class by ``name`` (str). | def get_feature(name):
"""Get an instance of a ``Features`` class by ``name`` (str)."""
if name == 'css':
return CSSFeatures()
elif name == 'kohlschuetter':
return KohlschuetterFeatures()
elif name == 'readability':
return ReadabilityFeatures()
elif name == 'weninger':
... | [
"def",
"get_feature",
"(",
"name",
")",
":",
"if",
"name",
"==",
"'css'",
":",
"return",
"CSSFeatures",
"(",
")",
"elif",
"name",
"==",
"'kohlschuetter'",
":",
"return",
"KohlschuetterFeatures",
"(",
")",
"elif",
"name",
"==",
"'readability'",
":",
"return",... | [
7,
0
] | [
20,
67
] | python | en | ['en', 'en', 'en'] | True |
AuthorizationMixin.authorization | (self) | The `Authorization` object in parsed form. | The `Authorization` object in parsed form. | def authorization(self):
"""The `Authorization` object in parsed form."""
header = self.environ.get("HTTP_AUTHORIZATION")
return parse_authorization_header(header) | [
"def",
"authorization",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"environ",
".",
"get",
"(",
"\"HTTP_AUTHORIZATION\"",
")",
"return",
"parse_authorization_header",
"(",
"header",
")"
] | [
12,
4
] | [
15,
49
] | python | en | ['en', 'en', 'en'] | True |
WWWAuthenticateMixin.www_authenticate | (self) | The `WWW-Authenticate` header in a parsed form. | The `WWW-Authenticate` header in a parsed form. | def www_authenticate(self):
"""The `WWW-Authenticate` header in a parsed form."""
def on_update(www_auth):
if not www_auth and "www-authenticate" in self.headers:
del self.headers["www-authenticate"]
elif www_auth:
self.headers["WWW-Authenticate"]... | [
"def",
"www_authenticate",
"(",
"self",
")",
":",
"def",
"on_update",
"(",
"www_auth",
")",
":",
"if",
"not",
"www_auth",
"and",
"\"www-authenticate\"",
"in",
"self",
".",
"headers",
":",
"del",
"self",
".",
"headers",
"[",
"\"www-authenticate\"",
"]",
"elif... | [
22,
4
] | [
32,
63
] | python | en | ['en', 'en', 'en'] | True |
DatabaseOperations.bulk_batch_size | (self, fields, objs) |
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of
999 variables per query.
If there's only a single field to insert, the limit is 500
(SQLITE_MAX_COMPOUND_SELECT).
|
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of
999 variables per query. | def bulk_batch_size(self, fields, objs):
"""
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of
999 variables per query.
If there's only a single field to insert, the limit is 500
(SQLITE_MAX_COMPOUND_SELECT).
"""
if len(fields) == 1:
... | [
"def",
"bulk_batch_size",
"(",
"self",
",",
"fields",
",",
"objs",
")",
":",
"if",
"len",
"(",
"fields",
")",
"==",
"1",
":",
"return",
"500",
"elif",
"len",
"(",
"fields",
")",
">",
"1",
":",
"return",
"self",
".",
"connection",
".",
"features",
"... | [
24,
4
] | [
37,
28
] | python | en | ['en', 'error', 'th'] | False |
DatabaseOperations.date_extract_sql | (self, lookup_type, field_name) |
Support EXTRACT with a user-defined function django_date_extract()
that's registered in connect(). Use single quotes because this is a
string and could otherwise cause a collision with a field name.
|
Support EXTRACT with a user-defined function django_date_extract()
that's registered in connect(). Use single quotes because this is a
string and could otherwise cause a collision with a field name.
| def date_extract_sql(self, lookup_type, field_name):
"""
Support EXTRACT with a user-defined function django_date_extract()
that's registered in connect(). Use single quotes because this is a
string and could otherwise cause a collision with a field name.
"""
return "djan... | [
"def",
"date_extract_sql",
"(",
"self",
",",
"lookup_type",
",",
"field_name",
")",
":",
"return",
"\"django_date_extract('%s', %s)\"",
"%",
"(",
"lookup_type",
".",
"lower",
"(",
")",
",",
"field_name",
")"
] | [
67,
4
] | [
73,
82
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.