Allow template render to string helper functions to accept Context (#372)

* Add failing test case for render_to_string

* Allow Context objects in template render functions
This commit is contained in:
Pavel Savchenko
2020-05-23 12:47:39 +02:00
committed by GitHub
parent 6f5a39625e
commit 64cbb0f70e
3 changed files with 20 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
from typing import Any, Dict, List, Optional, Union
from . import engines as engines # noqa: F401
from .context import Context
from django.http.request import HttpRequest
from django.template.exceptions import TemplateDoesNotExist as TemplateDoesNotExist # noqa: F401
@@ -8,7 +9,7 @@ def get_template(template_name: str, using: Optional[str] = ...) -> Any: ...
def select_template(template_name_list: Union[List[str], str], using: Optional[str] = ...) -> Any: ...
def render_to_string(
template_name: Union[List[str], str],
context: Optional[Dict[str, Any]] = ...,
context: Optional[Union[Context, Dict[str, Any]]] = ...,
request: Optional[HttpRequest] = ...,
using: Optional[str] = ...,
) -> str: ...