#35615: making request.auser available in templates when async is used -------------------------------------+------------------------------------- Reporter: amirreza | Owner: (none) Type: | Status: assigned Cleanup/optimization | Component: Template system | Version: 5.0 Severity: Normal | Resolution: Keywords: | Triage Stage: | Unreviewed Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Sarah Boyce):
* cc: Dingning, Jon Janzen, Andrew Godwin (added) Comment: Thank you for the ticket amirreza > so i have to await on request.auser on view and pass the result as context I can render `{{ request.user }}` in a template with a view such as {{{#!python async def test(request): request.user = await request.auser() return render(request, "test.html") }}} So yes, I do need to await request.auser I don't need to explicitly pass request to the template as context (ie I don't have to do `render(request, "test.html", {"request": request})`). > request.user is is used in more than one page, on a normal blog project we might be awaiting on auser in all of the views, i made some modifications to django.contrib.auth.AuthenticationMiddleware and django.utils.deprecation.MiddlewareMixin to ease the job. I think a decision needed as to whether we should be doing this in the middleware or not. CC-ing some contributors of this space to invite their thoughts Semi related: #35030 #35303 [https://forum.djangoproject.com/t/is-it- feasible-to-improve-streaming-html-in-django/21017/2 forum topic on async templates] -- Ticket URL: <https://code.djangoproject.com/ticket/35615#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070190ca8184f4-61c9d76d-90f5-4a82-9700-691077320db1-000000%40eu-central-1.amazonses.com.