mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-21 11:21:20 +08:00
initial commit
This commit is contained in:
1
django/contrib/admin/__init__.pyi
Normal file
1
django/contrib/admin/__init__.pyi
Normal file
@@ -0,0 +1 @@
|
||||
def autodiscover() -> None: ...
|
||||
11
django/contrib/admin/actions.pyi
Normal file
11
django/contrib/admin/actions.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.query import QuerySet
|
||||
from django.template.response import TemplateResponse
|
||||
|
||||
|
||||
def delete_selected(
|
||||
modeladmin: ModelAdmin,
|
||||
request: WSGIRequest,
|
||||
queryset: QuerySet
|
||||
) -> TemplateResponse: ...
|
||||
6
django/contrib/admin/apps.pyi
Normal file
6
django/contrib/admin/apps.pyi
Normal file
@@ -0,0 +1,6 @@
|
||||
class AdminConfig:
|
||||
def ready(self) -> None: ...
|
||||
|
||||
|
||||
class SimpleAdminConfig:
|
||||
def ready(self) -> None: ...
|
||||
132
django/contrib/admin/checks.pyi
Normal file
132
django/contrib/admin/checks.pyi
Normal file
@@ -0,0 +1,132 @@
|
||||
from django.contrib.admin.options import (
|
||||
BaseModelAdmin,
|
||||
InlineModelAdmin,
|
||||
ModelAdmin,
|
||||
TabularInline,
|
||||
)
|
||||
from django.contrib.auth.models import (
|
||||
Group,
|
||||
User,
|
||||
)
|
||||
from django.core.checks.messages import Error
|
||||
from django.db.models.base import Model
|
||||
from typing import (
|
||||
Any,
|
||||
List,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class BaseModelAdminChecks:
|
||||
def _check_autocomplete_fields(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_autocomplete_fields_item(
|
||||
self,
|
||||
obj: Union[ModelAdmin, InlineModelAdmin],
|
||||
model: Type[Model],
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_exclude(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_field_spec(
|
||||
self,
|
||||
obj: BaseModelAdmin,
|
||||
model: Any,
|
||||
fields: Union[str, Tuple[str, str, str, str], Tuple[str, str]],
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_field_spec_item(
|
||||
self,
|
||||
obj: BaseModelAdmin,
|
||||
model: Any,
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_fields(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_fieldsets(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_fieldsets_item(
|
||||
self,
|
||||
obj: BaseModelAdmin,
|
||||
model: Any,
|
||||
fieldset: Any,
|
||||
label: str,
|
||||
seen_fields: List[str]
|
||||
) -> List[Any]: ...
|
||||
def _check_filter_horizontal(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_filter_item(
|
||||
self,
|
||||
obj: ModelAdmin,
|
||||
model: Type[Union[Group, User]],
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_filter_vertical(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_form(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_ordering(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_ordering_item(
|
||||
self,
|
||||
obj: ModelAdmin,
|
||||
model: Any,
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_prepopulated_fields(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_prepopulated_fields_key(
|
||||
self,
|
||||
obj: Union[ModelAdmin, InlineModelAdmin],
|
||||
model: Type[Model],
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_prepopulated_fields_value(
|
||||
self,
|
||||
obj: BaseModelAdmin,
|
||||
model: Type[Model],
|
||||
val: Union[Tuple[str], List[str]],
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_prepopulated_fields_value_item(
|
||||
self,
|
||||
obj: Union[ModelAdmin, TabularInline],
|
||||
model: Type[Model],
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_radio_fields(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_raw_id_fields(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_raw_id_fields_item(
|
||||
self,
|
||||
obj: ModelAdmin,
|
||||
model: Type[Model],
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_readonly_fields(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def _check_readonly_fields_item(
|
||||
self,
|
||||
obj: BaseModelAdmin,
|
||||
model: Any,
|
||||
field_name: str,
|
||||
label: str
|
||||
) -> List[Any]: ...
|
||||
def _check_view_on_site_url(self, obj: BaseModelAdmin) -> List[Any]: ...
|
||||
def check(
|
||||
self,
|
||||
admin_obj: BaseModelAdmin,
|
||||
**kwargs
|
||||
) -> List[Error]: ...
|
||||
|
||||
|
||||
class InlineModelAdminChecks:
|
||||
def _check_exclude_of_parent_model(
|
||||
self,
|
||||
obj: InlineModelAdmin,
|
||||
parent_model: Any
|
||||
) -> List[Any]: ...
|
||||
def _check_extra(self, obj: InlineModelAdmin) -> List[Any]: ...
|
||||
def _check_formset(self, obj: InlineModelAdmin) -> List[Any]: ...
|
||||
def _check_has_add_permission(self, obj: InlineModelAdmin) -> None: ...
|
||||
def _check_max_num(self, obj: InlineModelAdmin) -> List[Any]: ...
|
||||
def _check_min_num(self, obj: InlineModelAdmin) -> List[Any]: ...
|
||||
def _check_relation(self, obj: InlineModelAdmin, parent_model: Any) -> List[Any]: ...
|
||||
4
django/contrib/admin/decorators.pyi
Normal file
4
django/contrib/admin/decorators.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def register(*models, site = ...) -> Callable: ...
|
||||
159
django/contrib/admin/filters.pyi
Normal file
159
django/contrib/admin/filters.pyi
Normal file
@@ -0,0 +1,159 @@
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields import (
|
||||
BooleanField,
|
||||
DateField,
|
||||
Field,
|
||||
)
|
||||
from django.db.models.fields.related import (
|
||||
ForeignKey,
|
||||
ManyToManyField,
|
||||
)
|
||||
from django.db.models.fields.reverse_related import ForeignObjectRel
|
||||
from django.db.models.query import QuerySet
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class AllValuesFieldListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
field: Field,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Type[Model],
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> None: ...
|
||||
def expected_parameters(self) -> List[str]: ...
|
||||
|
||||
|
||||
class BooleanFieldListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
field: BooleanField,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Type[Model],
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> None: ...
|
||||
def expected_parameters(self) -> List[str]: ...
|
||||
|
||||
|
||||
class ChoicesFieldListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
field: Field,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Type[Model],
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> None: ...
|
||||
def expected_parameters(self) -> List[str]: ...
|
||||
|
||||
|
||||
class DateFieldListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
field: DateField,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Type[Model],
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> None: ...
|
||||
def expected_parameters(self) -> List[str]: ...
|
||||
|
||||
|
||||
class FieldListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
field: Any,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Any,
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> None: ...
|
||||
@classmethod
|
||||
def create(
|
||||
cls,
|
||||
field: Any,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Any,
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> FieldListFilter: ...
|
||||
def has_output(self) -> bool: ...
|
||||
def queryset(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
queryset: QuerySet
|
||||
) -> QuerySet: ...
|
||||
@classmethod
|
||||
def register(cls, test: Callable, list_filter_class: Any, take_priority: bool = ...) -> None: ...
|
||||
|
||||
|
||||
class ListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Any,
|
||||
model_admin: ModelAdmin
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class RelatedFieldListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
field: Union[ForeignObjectRel, ManyToManyField, ForeignKey],
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Any,
|
||||
model_admin: ModelAdmin,
|
||||
field_path: str
|
||||
) -> None: ...
|
||||
def expected_parameters(self) -> List[str]: ...
|
||||
def field_choices(
|
||||
self,
|
||||
field: Union[ForeignObjectRel, ManyToManyField, ForeignKey],
|
||||
request: WSGIRequest,
|
||||
model_admin: ModelAdmin
|
||||
) -> Union[List[Tuple[str, str]], List[Tuple[int, str]]]: ...
|
||||
def has_output(self) -> bool: ...
|
||||
@property
|
||||
def include_empty_choice(self) -> bool: ...
|
||||
|
||||
|
||||
class RelatedOnlyFieldListFilter:
|
||||
def field_choices(
|
||||
self,
|
||||
field: Union[ManyToManyField, ForeignKey],
|
||||
request: WSGIRequest,
|
||||
model_admin: ModelAdmin
|
||||
) -> Union[List[Tuple[int, str]], List[Tuple[str, str]]]: ...
|
||||
|
||||
|
||||
class SimpleListFilter:
|
||||
def __init__(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
params: Dict[str, str],
|
||||
model: Type[Model],
|
||||
model_admin: ModelAdmin
|
||||
) -> None: ...
|
||||
def has_output(self) -> bool: ...
|
||||
def value(self) -> Optional[str]: ...
|
||||
5
django/contrib/admin/forms.pyi
Normal file
5
django/contrib/admin/forms.pyi
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class AdminAuthenticationForm:
|
||||
def confirm_login_allowed(self, user: User) -> None: ...
|
||||
75
django/contrib/admin/helpers.pyi
Normal file
75
django/contrib/admin/helpers.pyi
Normal file
@@ -0,0 +1,75 @@
|
||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||
from django.db.models.fields import AutoField
|
||||
from django.forms.utils import ErrorDict
|
||||
from django.forms.widgets import Media
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class AdminField:
|
||||
def errors(self) -> SafeText: ...
|
||||
def label_tag(self) -> SafeText: ...
|
||||
|
||||
|
||||
class AdminForm:
|
||||
def __init__(
|
||||
self,
|
||||
form: AdminPasswordChangeForm,
|
||||
fieldsets: List[Tuple[None, Dict[str, List[str]]]],
|
||||
prepopulated_fields: Dict[Any, Any],
|
||||
readonly_fields: None = ...,
|
||||
model_admin: None = ...
|
||||
) -> None: ...
|
||||
def __iter__(self) -> Iterator[Fieldset]: ...
|
||||
@property
|
||||
def errors(self) -> ErrorDict: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
@property
|
||||
def non_field_errors(self) -> Callable: ...
|
||||
|
||||
|
||||
class AdminReadonlyField:
|
||||
def contents(self) -> SafeText: ...
|
||||
def label_tag(self) -> SafeText: ...
|
||||
|
||||
|
||||
class Fieldline:
|
||||
def __iter__(
|
||||
self
|
||||
) -> Iterator[Union[AdminField, AdminReadonlyField]]: ...
|
||||
def errors(self) -> SafeText: ...
|
||||
|
||||
|
||||
class Fieldset:
|
||||
def __iter__(self) -> Iterator[Fieldline]: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
|
||||
|
||||
class InlineAdminForm:
|
||||
def __iter__(self) -> Iterator[InlineFieldset]: ...
|
||||
def deletion_field(self) -> AdminField: ...
|
||||
def fk_field(self) -> AdminField: ...
|
||||
def needs_explicit_pk_field(self) -> Union[bool, AutoField]: ...
|
||||
def pk_field(self) -> AdminField: ...
|
||||
|
||||
|
||||
class InlineAdminFormSet:
|
||||
def __iter__(self) -> Iterator[InlineAdminForm]: ...
|
||||
def fields(self) -> Iterator[Dict[str, Any]]: ...
|
||||
def inline_formset_data(self) -> str: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
|
||||
|
||||
class InlineFieldset:
|
||||
def __iter__(self) -> Iterator[Fieldline]: ...
|
||||
22
django/contrib/admin/models.pyi
Normal file
22
django/contrib/admin/models.pyi
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import Any
|
||||
|
||||
|
||||
class LogEntry:
|
||||
def __str__(self) -> str: ...
|
||||
def get_admin_url(self) -> str: ...
|
||||
def get_change_message(self) -> str: ...
|
||||
def is_addition(self) -> bool: ...
|
||||
def is_change(self) -> bool: ...
|
||||
def is_deletion(self) -> bool: ...
|
||||
|
||||
|
||||
class LogEntryManager:
|
||||
def log_action(
|
||||
self,
|
||||
user_id: int,
|
||||
content_type_id: int,
|
||||
object_id: int,
|
||||
object_repr: str,
|
||||
action_flag: int,
|
||||
change_message: Any = ...
|
||||
) -> LogEntry: ...
|
||||
73
django/contrib/admin/options.pyi
Normal file
73
django/contrib/admin/options.pyi
Normal file
@@ -0,0 +1,73 @@
|
||||
from django.core.checks.messages import Error
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.fields import Field
|
||||
from django.db.models.fields.related import (
|
||||
ForeignKey,
|
||||
ManyToManyField,
|
||||
)
|
||||
from django.db.models.query import QuerySet
|
||||
from django.forms.fields import TypedChoiceField
|
||||
from django.forms.models import (
|
||||
ModelChoiceField,
|
||||
ModelMultipleChoiceField,
|
||||
)
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class BaseModelAdmin:
|
||||
def __init__(self) -> None: ...
|
||||
def check(self, **kwargs) -> List[Error]: ...
|
||||
def formfield_for_choice_field(
|
||||
self,
|
||||
db_field: Field,
|
||||
request: object,
|
||||
**kwargs
|
||||
) -> TypedChoiceField: ...
|
||||
def formfield_for_dbfield(self, db_field: Field, request: object, **kwargs) -> Any: ...
|
||||
def formfield_for_foreignkey(
|
||||
self,
|
||||
db_field: ForeignKey,
|
||||
request: object,
|
||||
**kwargs
|
||||
) -> Optional[ModelChoiceField]: ...
|
||||
def formfield_for_manytomany(
|
||||
self,
|
||||
db_field: ManyToManyField,
|
||||
request: WSGIRequest,
|
||||
**kwargs
|
||||
) -> ModelMultipleChoiceField: ...
|
||||
def get_autocomplete_fields(self, request: object) -> Tuple: ...
|
||||
def get_empty_value_display(self) -> SafeText: ...
|
||||
def get_exclude(self, request: object, obj: Any = ...) -> None: ...
|
||||
def get_field_queryset(
|
||||
self,
|
||||
db: None,
|
||||
db_field: Union[ManyToManyField, ForeignKey],
|
||||
request: object
|
||||
) -> Optional[QuerySet]: ...
|
||||
def get_fields(self, request: object, obj: Any = ...) -> Union[List[Union[str, Callable]], List[str]]: ...
|
||||
def get_fieldsets(self, request: WSGIRequest, obj: Any = ...) -> Any: ...
|
||||
def get_ordering(self, request: WSGIRequest) -> Union[List[str], Tuple]: ...
|
||||
def get_prepopulated_fields(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
obj: Any = ...
|
||||
) -> Dict[str, Tuple[str]]: ...
|
||||
def get_queryset(self, request: object) -> QuerySet: ...
|
||||
def get_readonly_fields(self, request: object, obj: Any = ...) -> Union[Tuple, List[str]]: ...
|
||||
def get_sortable_by(self, request: WSGIRequest) -> Union[Tuple, List[str]]: ...
|
||||
def get_view_on_site_url(self, obj: Any = ...) -> Optional[str]: ...
|
||||
def has_add_permission(self, request: WSGIRequest) -> bool: ...
|
||||
def has_change_permission(self, request: object, obj: Any = ...) -> bool: ...
|
||||
def has_delete_permission(self, request: object, obj: Any = ...) -> bool: ...
|
||||
def has_module_permission(self, request: object) -> bool: ...
|
||||
def has_view_permission(self, request: WSGIRequest, obj: Any = ...) -> bool: ...
|
||||
77
django/contrib/admin/sites.pyi
Normal file
77
django/contrib/admin/sites.pyi
Normal file
@@ -0,0 +1,77 @@
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.http.response import (
|
||||
HttpResponse,
|
||||
HttpResponseRedirect,
|
||||
)
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls.resolvers import (
|
||||
URLPattern,
|
||||
URLResolver,
|
||||
)
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class AdminSite:
|
||||
def __init__(self, name: str = ...) -> None: ...
|
||||
def _build_app_dict(self, request: WSGIRequest, label: None = ...) -> Dict[Any, Any]: ...
|
||||
def add_action(self, action: Callable, name: None = ...) -> None: ...
|
||||
def admin_view(self, view: Callable, cacheable: bool = ...) -> Callable: ...
|
||||
def app_index(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
app_label: str,
|
||||
extra_context: None = ...
|
||||
) -> TemplateResponse: ...
|
||||
def check(self, app_configs: None) -> List[Any]: ...
|
||||
def get_action(self, name: str) -> Callable: ...
|
||||
def get_app_list(self, request: WSGIRequest) -> List[Any]: ...
|
||||
def get_urls(self) -> List[Union[URLPattern, URLResolver]]: ...
|
||||
def has_permission(self, request: WSGIRequest) -> bool: ...
|
||||
def i18n_javascript(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
extra_context: None = ...
|
||||
) -> HttpResponse: ...
|
||||
def index(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
extra_context: None = ...
|
||||
) -> TemplateResponse: ...
|
||||
def is_registered(self, model: Any) -> bool: ...
|
||||
def login(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
extra_context: None = ...
|
||||
) -> Union[HttpResponseRedirect, TemplateResponse]: ...
|
||||
def logout(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
extra_context: None = ...
|
||||
) -> TemplateResponse: ...
|
||||
def password_change(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
extra_context: Dict[str, str] = ...
|
||||
) -> TemplateResponse: ...
|
||||
def password_change_done(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
extra_context: None = ...
|
||||
) -> TemplateResponse: ...
|
||||
def register(self, model_or_iterable: Any, admin_class: Any = ..., **options) -> None: ...
|
||||
def unregister(self, model_or_iterable: Any) -> None: ...
|
||||
@property
|
||||
def urls(
|
||||
self
|
||||
) -> Union[Tuple[List[Union[URLPattern, URLResolver]], str, str], Tuple[List[URLPattern], str, str]]: ...
|
||||
|
||||
|
||||
class DefaultAdminSite:
|
||||
def _setup(self) -> None: ...
|
||||
109
django/contrib/admin/templatetags/admin_list.pyi
Normal file
109
django/contrib/admin/templatetags/admin_list.pyi
Normal file
@@ -0,0 +1,109 @@
|
||||
from django.contrib.admin.filters import FieldListFilter
|
||||
from django.contrib.admin.templatetags.base import InclusionAdminNode
|
||||
from django.contrib.admin.views.main import ChangeList
|
||||
from django.db.models.base import Model
|
||||
from django.forms.boundfield import BoundField
|
||||
from django.template.base import (
|
||||
Parser,
|
||||
Token,
|
||||
)
|
||||
from django.template.context import RequestContext
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def _boolean_icon(field_val: Optional[bool]) -> SafeText: ...
|
||||
|
||||
|
||||
def _coerce_field_name(field_name: Union[str, Callable], field_index: int) -> str: ...
|
||||
|
||||
|
||||
def admin_actions(context: RequestContext) -> RequestContext: ...
|
||||
|
||||
|
||||
def admin_actions_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def admin_list_filter(
|
||||
cl: ChangeList,
|
||||
spec: FieldListFilter
|
||||
) -> SafeText: ...
|
||||
|
||||
|
||||
def change_list_object_tools_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def date_hierarchy(cl: ChangeList) -> Any: ...
|
||||
|
||||
|
||||
def date_hierarchy_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def items_for_result(
|
||||
cl: ChangeList,
|
||||
result: Model,
|
||||
form: None
|
||||
) -> Iterator[SafeText]: ...
|
||||
|
||||
|
||||
def pagination(cl: ChangeList) -> Dict[str, Any]: ...
|
||||
|
||||
|
||||
def pagination_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def paginator_number(cl: ChangeList, i: int) -> SafeText: ...
|
||||
|
||||
|
||||
def result_headers(cl: ChangeList) -> Iterator[Dict[str, Union[None, int, str]]]: ...
|
||||
|
||||
|
||||
def result_hidden_fields(cl: ChangeList) -> Iterator[BoundField]: ...
|
||||
|
||||
|
||||
def result_list(cl: ChangeList) -> Dict[str, Any]: ...
|
||||
|
||||
|
||||
def result_list_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def results(
|
||||
cl: ChangeList
|
||||
) -> Iterator[ResultList]: ...
|
||||
|
||||
|
||||
def search_form(
|
||||
cl: ChangeList
|
||||
) -> Dict[str, Union[ChangeList, bool, str]]: ...
|
||||
|
||||
|
||||
def search_form_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
class ResultList:
|
||||
def __init__(self, form: None, *items) -> None: ...
|
||||
37
django/contrib/admin/templatetags/admin_modify.pyi
Normal file
37
django/contrib/admin/templatetags/admin_modify.pyi
Normal file
@@ -0,0 +1,37 @@
|
||||
from django.contrib.admin.helpers import InlineAdminForm
|
||||
from django.contrib.admin.templatetags.base import InclusionAdminNode
|
||||
from django.template.base import (
|
||||
Parser,
|
||||
Token,
|
||||
)
|
||||
from django.template.context import (
|
||||
Context,
|
||||
RequestContext,
|
||||
)
|
||||
|
||||
|
||||
def cell_count(inline_admin_form: InlineAdminForm) -> int: ...
|
||||
|
||||
|
||||
def change_form_object_tools_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def prepopulated_fields_js(context: RequestContext) -> RequestContext: ...
|
||||
|
||||
|
||||
def prepopulated_fields_js_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
|
||||
|
||||
def submit_row(context: RequestContext) -> Context: ...
|
||||
|
||||
|
||||
def submit_row_tag(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> InclusionAdminNode: ...
|
||||
1
django/contrib/admin/templatetags/admin_static.pyi
Normal file
1
django/contrib/admin/templatetags/admin_static.pyi
Normal file
@@ -0,0 +1 @@
|
||||
def static(path: str) -> str: ...
|
||||
23
django/contrib/admin/templatetags/admin_urls.pyi
Normal file
23
django/contrib/admin/templatetags/admin_urls.pyi
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.db.models.options import Options
|
||||
from django.template.context import RequestContext
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import (
|
||||
Dict,
|
||||
Optional,
|
||||
Union,
|
||||
)
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
def add_preserved_filters(
|
||||
context: Union[Dict[str, Union[str, Options]], RequestContext],
|
||||
url: str,
|
||||
popup: bool = ...,
|
||||
to_field: Optional[str] = ...
|
||||
) -> str: ...
|
||||
|
||||
|
||||
def admin_urlname(value: Options, arg: SafeText) -> str: ...
|
||||
|
||||
|
||||
def admin_urlquote(value: Union[str, UUID, int]) -> Union[str, UUID, int]: ...
|
||||
19
django/contrib/admin/templatetags/base.pyi
Normal file
19
django/contrib/admin/templatetags/base.pyi
Normal file
@@ -0,0 +1,19 @@
|
||||
from django.template.base import (
|
||||
Parser,
|
||||
Token,
|
||||
)
|
||||
from django.template.context import Context
|
||||
from django.utils.safestring import SafeText
|
||||
from typing import Callable
|
||||
|
||||
|
||||
class InclusionAdminNode:
|
||||
def __init__(
|
||||
self,
|
||||
parser: Parser,
|
||||
token: Token,
|
||||
func: Callable,
|
||||
template_name: str,
|
||||
takes_context: bool = ...
|
||||
) -> None: ...
|
||||
def render(self, context: Context) -> SafeText: ...
|
||||
16
django/contrib/admin/templatetags/log.pyi
Normal file
16
django/contrib/admin/templatetags/log.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.template.base import (
|
||||
Parser,
|
||||
Token,
|
||||
)
|
||||
from django.template.context import Context
|
||||
|
||||
|
||||
def get_admin_log(
|
||||
parser: Parser,
|
||||
token: Token
|
||||
) -> AdminLogNode: ...
|
||||
|
||||
|
||||
class AdminLogNode:
|
||||
def __init__(self, limit: str, varname: str, user: str) -> None: ...
|
||||
def render(self, context: Context) -> str: ...
|
||||
99
django/contrib/admin/utils.pyi
Normal file
99
django/contrib/admin/utils.pyi
Normal file
@@ -0,0 +1,99 @@
|
||||
from datetime import datetime
|
||||
from django.contrib.admin.options import (
|
||||
ModelAdmin,
|
||||
TabularInline,
|
||||
)
|
||||
from django.contrib.auth.forms import AdminPasswordChangeForm
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.fields.reverse_related import ManyToOneRel
|
||||
from django.db.models.options import Options
|
||||
from django.db.models.query import QuerySet
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
def _get_non_gfk_field(opts: Options, name: Union[str, Callable]) -> Any: ...
|
||||
|
||||
|
||||
def construct_change_message(
|
||||
form: AdminPasswordChangeForm,
|
||||
formsets: None,
|
||||
add: bool
|
||||
) -> List[Dict[str, Dict[str, List[str]]]]: ...
|
||||
|
||||
|
||||
def display_for_field(value: Any, field: Any, empty_value_display: str) -> str: ...
|
||||
|
||||
|
||||
def display_for_value(value: Any, empty_value_display: str, boolean: bool = ...) -> str: ...
|
||||
|
||||
|
||||
def flatten(fields: Union[Tuple, List[Union[str, Callable]], List[str]]) -> Union[List[Union[str, Callable]], List[str]]: ...
|
||||
|
||||
|
||||
def flatten_fieldsets(fieldsets: Any) -> Union[List[Union[str, Callable]], List[str]]: ...
|
||||
|
||||
|
||||
def get_fields_from_path(model: Any, path: str) -> Any: ...
|
||||
|
||||
|
||||
def get_model_from_relation(field: Any) -> Any: ...
|
||||
|
||||
|
||||
def help_text_for_field(name: str, model: Any) -> str: ...
|
||||
|
||||
|
||||
def label_for_field(
|
||||
name: Union[str, Callable],
|
||||
model: Any,
|
||||
model_admin: Optional[Union[ModelAdmin, TabularInline]] = ...,
|
||||
return_attr: bool = ...
|
||||
) -> Any: ...
|
||||
|
||||
|
||||
def lookup_field(
|
||||
name: Union[str, Callable],
|
||||
obj: Model,
|
||||
model_admin: Union[ModelAdmin, TabularInline] = ...
|
||||
) -> Any: ...
|
||||
|
||||
|
||||
def lookup_needs_distinct(opts: Options, lookup_path: str) -> bool: ...
|
||||
|
||||
|
||||
def model_ngettext(obj: QuerySet, n: None = ...) -> str: ...
|
||||
|
||||
|
||||
def prepare_lookup_value(key: str, value: Union[str, datetime]) -> Union[bool, datetime, str]: ...
|
||||
|
||||
|
||||
def quote(s: Union[str, UUID, int]) -> Union[str, UUID, int]: ...
|
||||
|
||||
|
||||
def reverse_field_path(model: Type[Model], path: str) -> Any: ...
|
||||
|
||||
|
||||
def unquote(s: str) -> str: ...
|
||||
|
||||
|
||||
class NestedObjects:
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
def _nested(self, obj: Model, seen: Any, format_callback: Callable) -> Any: ...
|
||||
def add_edge(self, source: Any, target: Model) -> None: ...
|
||||
def can_fast_delete(self, *args, **kwargs) -> bool: ...
|
||||
def collect(self, objs: Any, source: Any = ..., source_attr: Optional[str] = ..., **kwargs) -> None: ...
|
||||
def nested(self, format_callback: Callable = ...) -> Any: ...
|
||||
def related_objects(
|
||||
self,
|
||||
related: ManyToOneRel,
|
||||
objs: Any
|
||||
) -> QuerySet: ...
|
||||
11
django/contrib/admin/views/autocomplete.pyi
Normal file
11
django/contrib/admin/views/autocomplete.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models.query import QuerySet
|
||||
from django.http.response import JsonResponse
|
||||
|
||||
|
||||
class AutocompleteJsonView:
|
||||
def get(self, request: WSGIRequest, *args, **kwargs) -> JsonResponse: ...
|
||||
def get_paginator(self, *args, **kwargs) -> Paginator: ...
|
||||
def get_queryset(self) -> QuerySet: ...
|
||||
def has_perm(self, request: WSGIRequest, obj: None = ...) -> bool: ...
|
||||
8
django/contrib/admin/views/decorators.pyi
Normal file
8
django/contrib/admin/views/decorators.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from typing import Callable
|
||||
|
||||
|
||||
def staff_member_required(
|
||||
view_func: None = ...,
|
||||
redirect_field_name: str = ...,
|
||||
login_url: str = ...
|
||||
) -> Callable: ...
|
||||
55
django/contrib/admin/views/main.pyi
Normal file
55
django/contrib/admin/views/main.pyi
Normal file
@@ -0,0 +1,55 @@
|
||||
from collections import OrderedDict
|
||||
from django.contrib.admin.filters import SimpleListFilter
|
||||
from django.contrib.admin.options import ModelAdmin
|
||||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.db.models.base import Model
|
||||
from django.db.models.expressions import CombinedExpression
|
||||
from django.db.models.query import QuerySet
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Tuple,
|
||||
Type,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
class ChangeList:
|
||||
def __init__(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
model: Any,
|
||||
list_display: Union[Tuple[str, str, str, str], List[Union[str, Callable]], List[str]],
|
||||
list_display_links: Union[Tuple[str, str], List[str]],
|
||||
list_filter: Union[List[Type[SimpleListFilter]], Tuple, List[str]],
|
||||
date_hierarchy: Optional[str],
|
||||
search_fields: Union[List[str], Tuple],
|
||||
list_select_related: bool,
|
||||
list_per_page: int,
|
||||
list_max_show_all: int,
|
||||
list_editable: Union[List[str], Tuple],
|
||||
model_admin: ModelAdmin,
|
||||
sortable_by: Any
|
||||
) -> None: ...
|
||||
def _get_default_ordering(self) -> Union[List[str], Tuple[str], Tuple[str, str]]: ...
|
||||
def apply_select_related(self, qs: QuerySet) -> QuerySet: ...
|
||||
def get_filters(self, request: WSGIRequest) -> Any: ...
|
||||
def get_filters_params(self, params: None = ...) -> Dict[str, str]: ...
|
||||
def get_ordering(
|
||||
self,
|
||||
request: WSGIRequest,
|
||||
queryset: QuerySet
|
||||
) -> List[str]: ...
|
||||
def get_ordering_field(
|
||||
self,
|
||||
field_name: Union[str, Callable]
|
||||
) -> Optional[Union[str, CombinedExpression]]: ...
|
||||
def get_ordering_field_columns(self) -> OrderedDict: ...
|
||||
def get_query_string(self, new_params: Any = ..., remove: Optional[List[str]] = ...) -> str: ...
|
||||
def get_queryset(self, request: WSGIRequest) -> QuerySet: ...
|
||||
def get_results(self, request: WSGIRequest) -> None: ...
|
||||
def has_related_field_in_list_display(self) -> bool: ...
|
||||
def url_for_result(self, result: Model) -> str: ...
|
||||
149
django/contrib/admin/widgets.pyi
Normal file
149
django/contrib/admin/widgets.pyi
Normal file
@@ -0,0 +1,149 @@
|
||||
from datetime import datetime
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
from django.db.models.fields.reverse_related import (
|
||||
ForeignObjectRel,
|
||||
ManyToOneRel,
|
||||
)
|
||||
from django.forms.widgets import (
|
||||
Media,
|
||||
Select,
|
||||
)
|
||||
from django.http.request import QueryDict
|
||||
from django.utils.datastructures import MultiValueDict
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
List,
|
||||
Optional,
|
||||
Set,
|
||||
Tuple,
|
||||
Union,
|
||||
)
|
||||
|
||||
|
||||
def url_params_from_lookup_dict(lookups: Dict[str, Union[str, int]]) -> Dict[str, str]: ...
|
||||
|
||||
|
||||
class AdminDateWidget:
|
||||
def __init__(self, attrs: None = ..., format: None = ...) -> None: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
|
||||
|
||||
class AdminEmailInputWidget:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
|
||||
class AdminIntegerFieldWidget:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
|
||||
class AdminSplitDateTime:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Optional[datetime],
|
||||
attrs: Dict[str, Union[bool, str]]
|
||||
) -> Dict[str, Any]: ...
|
||||
|
||||
|
||||
class AdminTextInputWidget:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
|
||||
class AdminTextareaWidget:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
|
||||
|
||||
class AdminTimeWidget:
|
||||
def __init__(self, attrs: None = ..., format: None = ...) -> None: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
|
||||
|
||||
class AdminURLFieldWidget:
|
||||
def __init__(self, attrs: None = ...) -> None: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: None,
|
||||
attrs: Dict[str, str]
|
||||
) -> Dict[str, Union[Dict[str, Union[str, bool, None, Dict[str, str]]], str]]: ...
|
||||
|
||||
|
||||
class AutocompleteMixin:
|
||||
def __init__(
|
||||
self,
|
||||
rel: ManyToOneRel,
|
||||
admin_site: AdminSite,
|
||||
attrs: None = ...,
|
||||
choices: Tuple = ...,
|
||||
using: None = ...
|
||||
) -> None: ...
|
||||
def build_attrs(self, base_attrs: Dict[Any, Any], extra_attrs: Dict[str, str] = ...) -> Dict[str, str]: ...
|
||||
def get_url(self) -> str: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
def optgroups(
|
||||
self,
|
||||
name: str,
|
||||
value: List[str],
|
||||
attr: Dict[str, str] = ...
|
||||
) -> Union[List[Tuple[None, List[Dict[str, Union[str, int, Set[str], Dict[str, bool]]]], int]], List[Tuple[None, List[Dict[str, Union[bool, str]]], int]]]: ...
|
||||
|
||||
|
||||
class FilteredSelectMultiple:
|
||||
def __init__(self, verbose_name: str, is_stacked: bool, attrs: None = ..., choices: Tuple = ...) -> None: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
|
||||
|
||||
class ForeignKeyRawIdWidget:
|
||||
def __init__(
|
||||
self,
|
||||
rel: ManyToOneRel,
|
||||
admin_site: AdminSite,
|
||||
attrs: None = ...,
|
||||
using: None = ...
|
||||
) -> None: ...
|
||||
def base_url_parameters(self) -> Dict[str, str]: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: None,
|
||||
attrs: Dict[str, Union[bool, str]]
|
||||
) -> Dict[str, Union[Dict[str, Union[str, bool, None, Dict[str, Union[bool, str]]]], str]]: ...
|
||||
def url_parameters(self) -> Dict[str, str]: ...
|
||||
|
||||
|
||||
class RelatedFieldWidgetWrapper:
|
||||
def __deepcopy__(self, memo: Dict[int, Any]) -> RelatedFieldWidgetWrapper: ...
|
||||
def __init__(
|
||||
self,
|
||||
widget: Union[Select, AdminRadioSelect],
|
||||
rel: ForeignObjectRel,
|
||||
admin_site: AdminSite,
|
||||
can_add_related: Optional[bool] = ...,
|
||||
can_change_related: bool = ...,
|
||||
can_delete_related: bool = ...,
|
||||
can_view_related: bool = ...
|
||||
) -> None: ...
|
||||
def get_context(
|
||||
self,
|
||||
name: str,
|
||||
value: Optional[Union[str, int]],
|
||||
attrs: Dict[str, str]
|
||||
) -> Dict[str, Union[bool, str]]: ...
|
||||
def get_related_url(self, info: Tuple[str, str], action: str, *args) -> str: ...
|
||||
def id_for_label(self, id_: str) -> str: ...
|
||||
@property
|
||||
def is_hidden(self) -> bool: ...
|
||||
@property
|
||||
def media(self) -> Media: ...
|
||||
def value_from_datadict(
|
||||
self,
|
||||
data: QueryDict,
|
||||
files: MultiValueDict,
|
||||
name: str
|
||||
) -> Optional[str]: ...
|
||||
Reference in New Issue
Block a user