我如何知道下订单或提出请求的特定用户

问题描述 投票:0回答:1

我一直在想一件事,(我是 Django 的新手)如何了解正在发出请求或下订单的用户,而不必要求他们在登录后填写用户名表单已经

我一直在想一件事,(我是Django新手)如何了解发出请求的用户。

django-models django-rest-framework django-views django-forms django-templates
1个回答
0
投票
my_request_function( 
    request: HttpRequest, 
    *args, **kwargs,
) -> HttpResponse: 
    
    user = request.user

    # some more code to compute the template to render and the context
    # the template if necessary

    return render( request, my_template, my_context, )
© www.soinside.com 2019 - 2024. All rights reserved.