File: shortcuts.pyi

package info (click to toggle)
python-django-stubs 5.2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,832 kB
  • sloc: python: 5,185; makefile: 15; sh: 8
file content (49 lines) | stat: -rw-r--r-- 1,967 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from collections.abc import Callable, Mapping, Sequence
from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only

from django.db.models import Manager, QuerySet
from django.db.models.base import Model
from django.http import HttpRequest
from django.http.response import HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect
from django.utils.functional import _StrOrPromise

def render(
    request: HttpRequest | None,
    template_name: str | Sequence[str],
    context: Mapping[str, Any] | None = ...,
    content_type: str | None = ...,
    status: int | None = ...,
    using: str | None = ...,
) -> HttpResponse: ...
@type_check_only
class SupportsGetAbsoluteUrl(Protocol):
    def get_absolute_url(self) -> str: ...

@overload
def redirect(
    to: Callable[..., Any] | str | SupportsGetAbsoluteUrl,
    *args: Any,
    permanent: Literal[True],
    preserve_request: bool = False,
    **kwargs: Any,
) -> HttpResponsePermanentRedirect: ...
@overload
def redirect(
    to: Callable[..., Any] | str | SupportsGetAbsoluteUrl,
    *args: Any,
    permanent: Literal[False] = False,
    preserve_request: bool = False,
    **kwargs: Any,
) -> HttpResponseRedirect: ...
@overload
def redirect(
    to: Callable[..., Any] | str | SupportsGetAbsoluteUrl, *args: Any, permanent: bool, **kwargs: Any
) -> HttpResponseRedirect | HttpResponsePermanentRedirect: ...

_T = TypeVar("_T", bound=Model)

def get_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
async def aget_object_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> _T: ...
def get_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
async def aget_list_or_404(klass: type[_T] | Manager[_T] | QuerySet[_T], *args: Any, **kwargs: Any) -> list[_T]: ...
def resolve_url(to: Callable | Model | _StrOrPromise, *args: Any, **kwargs: Any) -> str: ...