Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render_block_to_string expects context to be "Context | None" instead of dict #57

Open
ma11011s opened this issue Aug 7, 2024 · 4 comments

Comments

@ma11011s
Copy link

ma11011s commented Aug 7, 2024

In the readme this example code is given:

print(render_block_to_string('test3.html', 'block3', {'variable': 'test'}))

but the code defines that context is not a dict but Optional[Context] = None:

def render_block_to_string(
    template_name: Union[str, Tuple[str], List[str]],
    block_name: str,
    context: Optional[Context] = None,
    request: Optional[HttpRequest] = None,
) -> str:

We could provide a Context object but i don't think that was intended to do :

from django.template import Context
print(render_block_to_string('test3.html', 'block3', Context({'variable': 'test'})))
@clokep
Copy link
Owner

clokep commented Aug 7, 2024

Is this a code issue or a type hint issue? Does the code in the README not work?

@ma11011s
Copy link
Author

ma11011s commented Aug 7, 2024

Sorry I should also have said that this is a typing issue. Should still be fixed in the code IMHO.

@clokep
Copy link
Owner

clokep commented Aug 7, 2024

Yes, definitely should be fixed. Luckily we don't export type hints yet. If you have time to make a PR that would be great.

@ma11011s
Copy link
Author

ma11011s commented Aug 7, 2024

I am not that experienced with github and pull requests, so i hope this PR is okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants